Пример #1
0
        private void MainTabControl_DragOver(object sender, DragEventArgs e)
        {
            TabPage source = (TabPage)e.Data.GetData(typeof(TabPage));

            //SetCurrStatus($"MainTabControl_DragOver:{source}");
            if (source != null)
            {
                for (int i = 0; i < MainTabControl.TabPages.Count; i++)
                {
                    if (MainTabControl.GetTabRect(i).Contains(MainTabControl.PointToClient(new Point(e.X, e.Y))))
                    {
                        if (MainTabControl.TabPages.IndexOf(source) != i)
                        {
                            e.Effect = DragDropEffects.Move;
                            TabAdapter.Swap(MainTabControl.TabPages.IndexOf(source), i);
                            MainTabControl.SelectedTab = source;
                            SetCurrStatus($"拖动结束:{source.Text}");
                            return;
                        }
                    }
                }
            }
            e.Effect = DragDropEffects.None;
        }