How do I programmatically show/hide a menu bar?
You can programmatically show or hide a menu bar by creating an event handler for its associated menu pad's Popup event. For example, if you want to hide a File | Print menu bar, you would do the following:
In C#:
- Select the File menu pad in the visual designer
- Go to the Properties Window and click the Events button
- Double-click the Popup event in the Properties Window. This creates a new event handler:
private void FilePad_Popup(object sender, System.EventArgs e) { } - Put code in this method that checks a condition and sets the Visible property of the menu bar:
private void FilePad_Popup(object sender, System.EventArgs e) { this.FilePrintBar.Visible = <Condition to be checked>; }
And in VB .NET:
- Go to the code window and in the combo box at the top left of the code window, select the File pad
- In the combo box at the top right of the code windodw, select the Popup event. This creates a new event handler:
Private Sub FileLocalizeSetupBar_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileLocalizeSetupBar.Popup End Sub
- Put code in this method that checks a condition and sets the Visible property of the menu bar:
Private Sub FileLocalizeSetupBar_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileLocalizeSetupBar.Popup Me.FilePrintBar.Visible = <Condition to be checked> End Sub
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/05/04
Comment or report problem with topic
