Ribbon for WinForms | ComponentOne
Run-Time Interaction / Customizing the Quick Access Toolbar
In This Topic
    Customizing the Quick Access Toolbar
    In This Topic

    The Quick Access Toolbar (QAT) can be customized in just a few click(s). You can add or remove items from the QAT as well as move the position of QAT above or below the Ribbon.

    Add or Remove items from QAT

    You can add the frequently-used commands to QAT at runtime. To add a command to the QAT at run-time:

    1. Select the item you want to add to QAT.
    2. Right-click the command. From the context menu, click on Add to Quick Access Toolbar.

    customize the qat

    You can also remove items from the QAT. To remove any item from the Quick Access Toolbar at runtime:

    1. Select the item you want to add to QAT.
    2. Right-click the command. From the context menu, click on Remove from Quick Access Toolbar.

    use context menu

    Move the Quick Access Toolbar

    You can display the QAT above or below the Ribbon, depending upon your requirements. To move the QAT below the Ribbon, click the drop-down arrow next to the QAT and select Show Below the Ribbon.

     select show below option

    To move the QAT back to its location above the Ribbon, click the drop-down arrow next to the QAT and select Show Above the Ribbon.

    select show above option

    Create Persistent QAT

    To retain the QAT behavior across application runs, use QatItemNames property of Ribbon class. This property saves the items that users add or delete to the QAT during runtime, ensuring they are preserved for future sessions.

    Below steps illustrate creating persistent QAT as shown in the following image:

    Persistent qat

    1. In Visual Studio, go to Project | <ProjectName> Properties | Settings.
    2. Click on Create or open application settings to open Settings designer.
    3. Add a new setting by specifying the name, type and scope (User or Application). For example, this code uses a setting value with name QatItems, of type String and scope User.
    4. Add the following code in FormClosing event to save the QAT items.
      C#
      Copy Code
      //Saving the items in QAT
      Properties.Settings.Default.QatItems = customRibbon.QatItemNames; 
      Properties.Settings.Default.Save();
      
      Note: Assign a value to the Name property of the RibbonItems so that the QatItemNames property saves these items.
    5. Add the following code in Load event to load the saved items back to QAT.
      C#
      Copy Code
      //Load the items saved in QatItems back to the QAT on the ribbon
      var savedQatItemNames = Properties.Settings.Default.QatItems;
      if (!string.IsNullOrEmpty(savedQatItemNames))
      {
          customRibbon.QatItemNames = savedQatItemNames;                
      }
      
    6. Run the application. In the first run, there are no items in QAT. Right click on the RibbonItems and add them to QAT. Close and rerun the application and observe the output.