Step 3: Adding an Application Menu

1. In the Solution Explorer, select the form Form1 and choose Designer from the View main menu.

2. Select the ribbon control and find the ApplicationMenuItems property in the Properties window.

3. Open the Control Collection Editor by clicking on the ellipsis button in the (Collection) value column of the ApplicationMenuItems property.

4. In the Control Collection Editor, click on Add to add a new Windows.Forms.Ribbon.RibbonButton. Name this button m_rbtnLoad and set the Text property to Load.... Add a second button with the name m_rbtnSave and the Text Save.... Close the dialog by clicking OK.

5. In the Solution Explorer, select the form Form1 and choose Code from the View main menu. Attach two more events to the Form1 constructor code, so that the complete constructor code looks like this:

[C#]
public Form1()
{
    InitializeComponent();

    textControl1.InputPositionChanged += TextControl1_InputPositionChanged;
    textControl1.FrameSelected += TextControl1_FrameSelected;
    textControl1.FrameDeselected += TextControl1_FrameDeselected;
    textControl1.DrawingActivated += TextControl1_DrawingActivated;
    textControl1.DrawingDeselected += TextControl1_DrawingDeselected;

    m_rbtnLoad.Click += M_rbtnLoad_Click;
    m_rbtnSave.Click += M_rbtnSave_Click;
}
[Visual Basic]
Public Sub New()
    InitializeComponent()

    textControl1.InputPositionChanged += TextControl1_InputPositionChanged
    textControl1.FrameSelected += TextControl1_FrameSelected
    textControl1.FrameDeselected += TextControl1_FrameDeselected
    textControl1.DrawingActivated += TextControl1_DrawingActivated
    textControl1.DrawingDeselected += TextControl1_DrawingDeselected

    AddHandler m_rbtnLoad.Click, AddressOf M_rbtnLoad_Click
    AddHandler m_rbtnSave.Click, AddressOf M_rbtnSave_Click
End Sub

6. Under the Form constructor code, add the following two new event handler methods:

[C#]
private void M_rbtnSave_Click(object sender, EventArgs e)
{
    textControl1.Save();
}

private void M_rbtnLoad_Click(object sender, EventArgs e)
{
    textControl1.Load();
}
[Visual Basic]
Private Sub M_rbtnSave_Click(sender As Object, e As EventArgs)
    textControl1.Save()
End Sub

Private Sub M_rbtnLoad_Click(sender As Object, e As EventArgs)
    textControl1.Load()
End Sub

7. Build and start the application.

When clicking on the File application menu, the two menu items are visible to load and save documents.

<< Step 2: Adding Contextual Ribbon Tabs