Launching a Form from the Main Menu

Follow these steps to launch a custom form from the main menu.

  1. Add a new menu bar for launching the new form to the main application window's menu. Name the bar something descriptive - our convention is to use the name of the menu pad as the prefix, the text of the menu bar as the next portion of the name, and the word "bar" as a suffix. For example: FileExitBar (where File is the name of the menu pad and Exit is the text of the menu bar).

  2. Double-click the new menu bar. This creates an event handler method that is given the same name as your menu bar class with an _Click suffix. For example: ActivitiesRunSampleCodeBar_Click().

    The following sample code instantiates an MDI child form.

    In C#:

    private void ActivitiesRunSampleCodeBar_Click(object sender,System.EventArgs e)
    {
    	mmAppDesktop.FormMgr.Show(new SampleCodeForm(), this);
    }

    In VB .NET:

    Private Sub ActivitiesRunSampleCodeBar_Click(sender As Object, e As System.EventArgs)
       mmAppDesktop.FormMgr.Show(New SampleCodeForm(), Me)
    End Sub

    And this code instantiates a non-MDI form.

    In C#:

    private void ActivitiesRunSampleCodeBar_Click(object sender,System.EventArgs e)
    {
    	mmAppDesktop.FormMgr.Show(new SampleCodeForm());
    }

    In VB .NET:

    Private Sub ActivitiesRunSampleCodeBar_Click(sender As Object, e As System.EventArgs)
       mmAppDesktop.FormMgr.Show(New SampleCodeForm())
    End Sub

    And this code instantiates a modal dialog:

    In C#:

    private void ActivitiesRunSampleCodeBar_Click(object sender,System.EventArgs e)
    {
    	DialogResult Result = mmAppDesktop.FormMgr.ShowDialog(new SampleCodeForm());
    	// Check Result here and process accordingly
    }

    In VB .NET:

    Private Sub ActivitiesRunSampleCodeBar_Click(sender As Object, e As System.EventArgs)
       Result As DialogResult = mmAppDesktop.FormMgr.ShowDialog(New SampleCodeForm())
       ' Check Result here and process accordingly
    End Sub



Note: Using the MM .NET Form Manager's Show and ShowDialog methods allow your forms to be displayed properly whether or not your application is localized. For details, see the MM .NET topic Showing Localized Windows Forms


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 03/13/08
Comment or report problem with topic