Articles in this section
Category / Section

How to find the WinForms Docking Manager control which is currently active in tabbed group?

1 min read

Tabbed group

DockTabControl has an event which name is SelectedIndexChanged can give the details about the currently active control in the DockTabbedGroup. DockTabControl has the SelectedTab property which give the current active control in the group.

The following code snippet explain the above concept,

C#

private void dockTabControl_SelectedindexChanging (object sender, EventArgs e)
{
   if(sender is DockTabControl)
   {
      DockTabControl tabcontrol = sender as DockTabControl;
      string str = (string)tabcontrol.Tag;
      //Checks whether the DockTabControl.Tag is left or right.
      if(tabcontrol.SelectedTab !=null)
      {
         if (str == "left")
            Console.WriteLine("Selected Control on the left : " + tabcontrol.SelectedTab.Text);
         else
            Console.WriteLine("Selected Control on the right : " + tabcontrol.SelectedTab.Text);
      }
   }
}

 

VB

Private Sub dockTabControl_SelectedindexChanging(ByVal sender As Object, ByVal e As EventArgs)
   If TypeOf sender Is DockTabControl Then
      Dim tabcontrol As DockTabControl = CType(IIf(TypeOf sender Is DockTabControl, sender, Nothing), DockTabControl)
      Dim str As String = CStr(tabcontrol.Tag)
      'Checks whether the DockTabControl.Tag is left or right.
      If Not tabcontrol.SelectedTab is Nothing Then
         If str = "left" Then
            Console.WriteLine("Selected Control on the left : " & tabcontrol.SelectedTab.Text)
         Else
            Console.WriteLine("Selected Control on the right : " & tabcontrol.SelectedTab.Text)
         End If
      End If
   End If
End Sub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied