We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to select the tab programmatically in WinForms TabbedMDIManager?

Platform: WinForms |
Control: TabbedMDIManager |
.NET Framework: 4

Select the tab programmatically

Since the TabControlAdv has been used internally to display the items in Tabbed structure, we can use the properties of TabControlAdv to change the selected tab programmatically in TabbedMDIManager. The following code snippet demonstrates how to change the selected tab programmatically through SelectedIndex and SelectedTab property of TabControlAdv,


public partial class Form1 : Form
  public Form1()
    this.textBox1.KeyDown += TextBox1_KeyDown;
    this.tabbedMDIManager1.TabControlAdded += TabbedMDIManager1_TabControlAdded;
  TabControlAdv tabcontrol;
  private void TabbedMDIManager1_TabControlAdded(object sender, TabbedMDITabControlEventArgs args)
    tabcontrol = args.TabControl;            
  private void TextBox1_KeyDown(object sender, KeyEventArgs e)
    if(e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(textBox1.Text))
      int index = Convert.ToInt32(textBox1.Text); 
      //We can also change selected index using SelectedIndex property
      //tabcontrol.SelectedIndex = index;
      tabcontrol.SelectedTab = tabcontrol.TabPages[index];
  private void AddItems()
    for (int i = 0; i <= 10; i++)
      Form2 form = new Form2();
      form.MdiParent = this;
      form.Text = "Form" +i;


Partial Public Class Form1
  Inherits Form
  Public Sub New()
    AddHandler Me.textBox1.KeyDown, AddressOf TextBox1_KeyDown
    AddHandler Me.tabbedMDIManager1.TabControlAdded, AddressOf TabbedMDIManager1_TabControlAdded   
  End Sub
  Private tabcontrol As TabControlAdv
  Private Sub TabbedMDIManager1_TabControlAdded(ByVal sender As Object, ByVal args As TabbedMDITabControlEventArgs)
    tabcontrol = args.TabControl
  End Sub
  Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    If e.KeyCode = Keys.Enter AndAlso Not String.IsNullOrEmpty(textBox1.Text) Then
      Dim index As Integer = Convert.ToInt32(textBox1.Text)
      'We can also change selected index using SelectedIndex property
      'tabcontrol.SelectedIndex = index;
      tabcontrol.SelectedTab = tabcontrol.TabPages(index)
    End If
  End Sub
  Private Sub AddItems()
    For i As Integer = 0 To 10
      Dim form As New Form2()
      form.MdiParent = Me
      form.Text = "Form" & i
    Next i
  End Sub
End Class


Show Form 7 is selected based on the input

   Form7 has been selected based on the input


C#: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CSharp_TabbedMDIManager_SelectedTab-869554543.zip

VB: https://www.syncfusion.com/downloads/support/directtrac/general/ze/VB_TabbedMDIManager_SelectedTab-1296623199.zip


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile