How to get Ribbon tabs and button list

Feb 18, 2014 at 7:00 AM
Hi,
I want to change ribbon button and tabs text dynamically. For form control i can do like this.

private static void load_lang(Control ctr)
    {

        ctr.Font = new Font(font_name, font_size);
        ctr.Text = lang_adpt.ScalarLangValueByName(ctr.Name).ToString();
        foreach (Control c in ctr.Controls)
        {
            c.Font = new Font(font_name, font_size);
            c.Text =  lang_adpt.ScalarLangValueByName(ctr.Name).ToString();
            if (c.HasChildren)
            {
                load_lang(c);
            }

        }

    }
How can i do for ribbon buttons and tabs? anyone can help me?
Feb 18, 2014 at 8:14 AM
Hello myomyintaung512,

I'm using this code in Vb.Net:
        For IntTab As Integer = 0 To Me.rbMain.Tabs.Count - 1
            Debug.WriteLine("tab: " & rbMain.Tabs(IntTab).Name)
            For intPnl As Integer = 0 To rbMain.Tabs(IntTab).Panels.Count - 1
                Debug.WriteLine("  pnl: " & rbMain.Tabs(IntTab).Panels(intPnl).Name)
                For intItem As Integer = 0 To rbMain.Tabs(IntTab).Panels(intPnl).Items.Count - 1
                    Debug.WriteLine("    item: " & rbMain.Tabs(IntTab).Panels(intPnl).Items(intItem).Name)
                    Select Case rbMain.Tabs(IntTab).Panels(intPnl).Items(intItem).GetType.Name
                        Case "RibbonButton"
                            Dim myBt As RibbonButton = rbMain.Tabs(IntTab).Panels(intPnl).Items(intItem)
                            For intcount As Integer = 0 To myBt.DropDownItems.Count - 1
                                Debug.WriteLine("    >>" & myBt.DropDownItems(intcount).Name)
                            Next
                        Case "RibbonButtonList"
                            Dim myBt As RibbonButtonList = rbMain.Tabs(IntTab).Panels(intPnl).Items(intItem)
                            For intcount As Integer = 0 To myBt.DropDownItems.Count - 1
                                Debug.WriteLine("    >>" & myBt.DropDownItems(intcount).Name)
                            Next
                        Case "RibbonCheckBox"

                    End Select
                Next
            Next
        Next
Best regards
Marked as answer by myomyintaung512 on 2/18/2014 at 12:56 AM
Feb 18, 2014 at 8:50 AM
Font is not supported. It is the same Font for all ribbon items.
Each ribbon container item has some kind of item collection, e.g. RibbonTabCollection on the ribbon itself.
Feb 18, 2014 at 8:54 AM
Hi BredRick,

Thanks you so much on your help. I spent a lot of time on it but i still cannot find the solution. Your's is perfect for me. Thanks you for giving time.

Here is my c# version code.

foreach (RibbonTab tab in ribbonMainForm.Tabs)
            {
                MessageBox.Show(tab.Text);
                foreach (RibbonPanel pnl in tab.Panels)
                {
                    MessageBox.Show(pnl.Text);
                    foreach(RibbonItem itm in pnl.Items ){
                        switch (itm.GetType().Name)
                        {
                            case "RibbonButton":
                                MessageBox.Show("Button " + itm.Text);
                                break;
                            case "RibbonButtonList":
                                MessageBox.Show("RibbonButtonList "+itm.Text);
                                break;
                            case "RibbonCheckBox":
                                MessageBox.Show("RibbonButtonList " + itm.Text);
                                break;
                        }
                    }
                }
            }
With Best Regards,
Myo Myint Aung (Juno)
Marked as answer by myomyintaung512 on 2/18/2014 at 12:56 AM