This is a migrated thread and some comments may be shown as answers.

RadRibbonGroup or Tab UserControl

1 Answer 94 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Psibernetic
Top achievements
Rank 1
Psibernetic asked on 01 Oct 2013, 06:27 PM
Hi I am trying to determine how I would need to go about encapsulating a Ribbon Tab so that it can be used in several different places, otherwise I will have to write some slightly unpleasant code for determining the context of the contextual tab and making the buttons interact accordingly.

1 Answer, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 04 Oct 2013, 01:09 PM
Hi Psiberbernetic,

Thank you for contacting us.

You can create a class which derives from RibbonTab with some predefined elements inside:
public class MyRibbonTab : Telerik.WinControls.UI.RibbonTab
{
    private RadRibbonBarGroup group;
    private RadButtonElement button;
    private string name;
 
    public MyRibbonTab(string name)
    {
        this.AccessibleDescription = name;
        this.AccessibleName = name;
        this.IsSelected = false;
        this.Name = name;
        this.Text = name;
        this.Visibility = ElementVisibility.Visible;
    }
 
    public RadRibbonBarGroup Group
    {
        get
        {
            return this.group;
        }
    }
 
    public RadButtonElement Button
    {
        get
        {
            return this.button;
        }
    }
 
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
 
        this.group = new RadRibbonBarGroup();
        this.group.AccessibleDescription = "Group";
        this.group.AccessibleName = "Group";
        this.group.Name = "Group";
        this.group.Text = "Group";
        this.group.Visibility = ElementVisibility.Visible;
 
        this.button = new RadButtonElement();
        this.button.AccessibleDescription ="Button";
        this.button.AccessibleName = "Button";
        this.button.Name = "Button";
        this.button.Text = "Button";
        this.button.Visibility = ElementVisibility.Visible;
        this.button.MinSize = new Size(100,50);
        this.button.InvalidateArrange(true);
 
        this.Items.Add(this.group);
        this.group.Items.Add(this.button);
 
        this.button.Click += button_Click;
    }
 
    void button_Click(object sender, EventArgs e)
    {
        RadMessageBox.Show("Click");
    }
}

You can add the tab as follows:
for (int i = 0; i < 4; i++)
{
    this.radRibbonBar1.CommandTabs.Add(new MyRibbonTab("Tab " + i));
}

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RibbonBar
Asked by
Psibernetic
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or