public void ux_tabcontrolMouseDownEvent(TabControl ux_tabcontrolDataview, MouseEventArgs e) { int clickedTabPage = ux_tabcontrolDataview.SelectedIndex; // Attempt to find the tabpage that was clicked... for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++) { if (ux_tabcontrolDataview.GetTabRect(i).Contains(e.Location)) clickedTabPage = i; //MessageBox.Show(ux_tabcontrolDataview.TabPages[i].Text + " : " + e.Location.ToString()); } if (e.Button == MouseButtons.Left) { // Begin tabpage drag and drop move (if the clicked tab is not // the "ux_tabpageDataviewNewTab" tabpage - which is use to add new dataviews)... if (ux_tabcontrolDataview.TabPages[clickedTabPage] != ux_tabcontrolDataview.TabPages["ux_tabpageDataviewNewTab"]) { ux_tabcontrolDataview.DoDragDrop(ux_tabcontrolDataview.TabPages[clickedTabPage], DragDropEffects.Move); } } else if (e.Button == MouseButtons.Right) { // Make the right clicked tabpage the selected tabpage for the control... ux_tabcontrolDataview.SelectTab(clickedTabPage); } }