)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the order of the ToolStripTabItems in WinForms RibbonControlAdv?

Platform: WinForms |
Control: RibbonControlAdv |
Published Date: January 2, 2015 |
Last Revised Date: January 8, 2020

Change the order of ToolStripTabItems

The ToolStripTabItem display index can be modified by reorganizing them in RibbonControlAdv.

C#

void ChangeToolStripOrder()
{
     ArrayList toolStripTabitems = new ArrayList();
     foreach (Control ctrl in this.Controls)
     {
         if (ctrl is RibbonControlAdv)
         {
             RibbonControlAdv ribbonctrl = ctrl as RibbonControlAdv;
             foreach (object item in ribbonctrl.Header.MainItems)
             {
                 if (item is ToolStripTabItem)
                 {
                    toolStripTabitems.Add(item);
                 }
             }
             int iterator = ribbonctrl.Header.MainItems.Count;
             while (iterator > 0)
             {
                 ribbonctrl.Header.MainItems.RemoveAt(0);
                 iterator = ribbonctrl.Header.MainItems.Count;
             }
             for (iterator = toolStripTabitems.Count-1; iterator >= 0; iterator--)
             {
                 ribbonctrl.Header.AddMainItem(toolStripTabitems[iterator] as ToolStripTabItem);
             }
             break;
         }
     }
}

VB

Private Sub ChangeToolStripOrder()
     Dim toolStripTabitems As New ArrayList()
     For Each ctrl As Control In Me.Controls
         If TypeOf ctrl Is RibbonControlAdv Then
            Dim ribbonctrl As RibbonControlAdv = TryCast(ctrl, RibbonControlAdv)
            For Each item As Object In ribbonctrl.Header.MainItems
                If TypeOf item Is ToolStripTabItem Then
                   toolStripTabitems.Add(item)
                End If
            Next
            Dim iterator As Integer = ribbonctrl.Header.MainItems.Count
            While iterator > 0
                 ribbonctrl.Header.MainItems.RemoveAt(0)
                    iterator = ribbonctrl.Header.MainItems.Count
            End While
            For iterator = toolStripTabitems.Count - 1 To 0 Step -1
                 ribbonctrl.Header.AddMainItem(TryCast(toolStripTabitems(iterator), ToolStripTabItem))
            Next
         Exit For
       End If
   Next
End Sub

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/RibbonControlAsmple720844179.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon