Articles in this section
Category / Section

How to hide the main form's toolbars from a child form in WinForms Menu(MainFrameBarManager)?

1 min read

Hide the mainform toolbars from a child form

For doing this MainFrameBarManager of the parent form has to be accessed and then its bar visibility has to be set as False using the method SetBarVisibility. Please refer the below code snippet which illustrates this:

C#

//Get hold of the MDIParentForm1
parent = this.MdiParent as Form1;
// Get the MainFrameBarManager in the MDI parent.
MainFrameBarManager mainManager = parent.mainFrameBarManager1;
// Parse through the bars, and hide them.
foreach(Bar bar in mainManager.Bars)
{
   mainManager.GetCommandBarManager().SetBarVisibility(bar, false);
}

VB

'Get hold of the MDIParent
Dim parent As Form1 = Me.MdiParent
’ Get the MainFrameBarManager in the MDI parent.
Dim mainManager As MainFrameBarManager = parent.mainFrameBarManager1
’ Parse through the bars, and hide them.
Dim bar As Bar
For Each bar In mainManager.Bars
   mainManager.GetCommandBarManager().SetBarVisibility(bar, False)
Next

 

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