When using Document Docking DotNetBar functionality usually there is a need to find out the Bar control that has input focus, for example if you are hosting edit controls.

To do that you would use standard Windows Forms methods. For example following function can be used to get the active bar:

C#

private Bar GetActiveBar()
{
    DevComponents.DotNetBar.Bar bar = null;
 
    if (this.ActiveControl != null)
    {
        Control c = this.ActiveControl;
 
        while (c != null)
        {
            if (c is DevComponents.DotNetBar.Bar)
            {
                bar = c as DevComponents.DotNetBar.Bar;
                break;
            }
 
            c = c.Parent;
        }
    }
 
    return bar;
}

VB

Private Function GetActiveBar() As DevComponents.DotNetBar.Bar
    Dim bar As DevComponents.DotNetBar.Bar = Nothing
 
    If Not Me.ActiveControl Is Nothing Then
        Dim c As Control = Me.ActiveControl
 
        While Not c Is Nothing
            If TypeOf (c) Is DevComponents.DotNetBar.Bar Then
                bar = DirectCast(c, DevComponents.DotNetBar.Bar)
                Exit While
            End If
 
            c = c.Parent
 
        End While
    End If
 
    Return bar
 
End Function

You would then use this function like this from your code:

C#

Bar bar = GetActiveBar();
 
if (bar != null)
    Console.WriteLine("Active Bar is " + bar.Name + " Selected Dock Container item is " + bar.SelectedDockContainerItem.Text);
else
    Console.WriteLine("No active bar");

VB

Dim bar As DevComponents.DotNetBar.Bar = GetActiveBar()
 
If Not bar Is Nothing Then
    Console.WriteLine("Active bar is " + bar.Name + " Selected Document is " + bar.SelectedDockContainerItem.Name)
Else
    Console.WriteLine("No active bar")
End If

Related posts:

  1. How to cycle through active docked documents using Ctrl+Tab key combination
  2. How to find CrumBarItem in CrumbBar control by name
  3. How to enumerate through all nodes in AdvTree control
  4. DotNetBar for WinForms Document Docking
  5. How to to change top-most behavior of floating bars