ComponentOne Ribbon for WinForms
C1Ribbon (Classic) Task-Based Help / Working with the Application Menu / Creating the Application Menu
In This Topic
    Creating the Application Menu
    In This Topic

    By default, the Application menu is empty, and you can add as many or as few items to the menu to fit your needs. The following steps demonstrate how to customize the main application button's drop-down menu.

    To Create the Start Menu Using the Collection Editor

    Complete the following steps:

    1. Click the Application button to reveal the list of Application menu properties in the Properties window.
    2. From the Properties window, select the LeftPaneItems property and click the ellipsis button at the right side of the (Collection).
      The RibbonApplicationMenu LeftPaneItems Collection Editor appears.
    3. Click the Add drop-down arrow and select RibbonButton. Repeat this step to add two more Ribbon buttons.
      You should now have three buttons added to the Members list:
    4. Select the first button in the list to edit its properties using the collection editor's Properties window. Set the following properties for the first button:
      • By default, the RibbonButton.Text property is set to Button. Delete the text and set it to &New.
      • Click the RibbonItem.LargeImage property drop-down button, then click the second drop-down button and choose the New image from the list.
    5. Select the second button in the list and set the following properties using the collection editor's Properties window:
      • By default, the RibbonButton.Text property is set to Button. Delete the text and set it to &Open.
      • Click the RibbonItem.LargeImage property drop-down button, then click the second drop-down button and choose the Open image from the list.
    6. Select the third button in the list and set the following properties using the collection editor's Properties window:
      • By default, the RibbonButton.Text property is set to Button. Delete the text and set it to &Save.
      • Click the RibbonItem.LargeImage property drop-down button, then click the second drop-down button and choose the Save image from the list.
    7. Click OK to close the collection editor.

    To Create the Start Menu Programmatically

    Note: In the following example embedded resources containing the following (32x32) images are used: NewBtn.png, OpenBtn.png, and SaveBtn.png. To embed a resource, from the Project menu, choose YourProjectName Properties. From the Resources tab, select Add Resource and choose to add an existing file or add a new one.

    To create a Start menu of commands, add the following code to your project:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Include the Imports directive for the namespace
    Imports C1.Win.C1Ribbon
     
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Create the items for the left pane
        Dim NewButton As RibbonButton = New RibbonButton()
        Dim OpenButton As RibbonButton = New RibbonButton()
        Dim SaveButton As RibbonButton = New RibbonButton()
     
        ' Add items to the left pane menu
        Me.C1Ribbon1.ApplicationMenu.LeftPane.Items.Add(NewButton)
        Me.C1Ribbon1.ApplicationMenu.LeftPane.Items.Add(OpenButton)
        Me.C1Ribbon1.ApplicationMenu.LeftPane.Items.Add(SaveButton)
     
        ' Set properties for the left pane items
        NewButton.Text = "&New"
        NewButton.LargeImage = My.Resources.Resources.NewBtn
        OpenButton.Text = "&Open"
        OpenButton.LargeImage = My.Resources.Resources.OpenBtn
        SaveButton.Text = "&Save"
        SaveButton.LargeImage = My.Resources.Resources.SaveBtn
    End Sub
    

    To write code in C#

    C#
    Copy Code
    // Include the using directive for the namespace
    using C1.Win.C1Ribbon;
     
    private void Form1_Load(object sender, System.EventArgs e)
    {
        // Create the items for the left pane
        RibbonButton NewButton = new RibbonButton();
        RibbonButton OpenButton = new RibbonButton();
        RibbonButton SaveButton = new RibbonButton();
     
        // Add items to the left pane menu
        this.c1Ribbon1.ApplicationMenu.LeftPane.Items.Add(NewButton);
        this.c1Ribbon1.ApplicationMenu.LeftPane.Items.Add(OpenButton);
        this.c1Ribbon1.ApplicationMenu.LeftPane.Items.Add(SaveButton);
     
        // Set properties for the left pane items
        NewButton.Text = "&New";
        NewButton.LargeImage = Properties.Resources.NewBtn;
        OpenButton.Text = "&Open";
        OpenButton.LargeImage = Properties.Resources.OpenBtn;
        SaveButton.Text = "&Save";
        SaveButton.LargeImage = Properties.Resources.SaveBtn;
    }
    

    This topic illustrates the following:

    Run the application and click the main application button to reveal the drop-down menu of commands: