Live Chat Icon For mobile
Live Chat Icon

How can I drag and drop TabPages between TabControls?

Platform: WinForms| Category: TabControl

The following code snippet shows how you can drag a TabPage from TabControl1 and drop it into TabControl2 (whose AllowDrop property must be set to True):

Source TabControl
private void tabControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 if (e.Button == MouseButtons.Left)

//Target TabControl
private void tabControl2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)

	e.Effect = DragDropEffects.Move;
	e.Effect = DragDropEffects.None;

private void tabControl2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 TabPage DropTab = (TabPage)(e.Data.GetData (typeof(TabPage)));
 this.tabControl2.TabPages.Add (DropTab);


’Source TabControl
Private  Sub tabControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
 If e.Button = MouseButtons.Left Then
 End If
End Sub
’Target TabControl
Private  Sub tabControl2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
 If e.Data.GetDataPresent(Type.GetType(TabPage)) Then
	e.Effect = DragDropEffects.Move
	e.Effect = DragDropEffects.None
 End If
End Sub
Private  Sub tabControl2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
 Dim DropTab As TabPage = CType((e.Data.GetData(Type.GetType(TabPage))), TabPage)
 Me.tabControl2.TabPages.Add (DropTab)
End Sub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.