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

items in tabular fashion in RadRibbonbarButtons

1 Answer 59 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Mahesh V
Top achievements
Rank 2
Mahesh V asked on 30 Oct 2012, 10:15 AM
Hi,

I want to add 8 radio buttons , in tabular fashion in radribbon bar(Please check in attached image).
I have added a  RadRibbonbarGroup=>2 horizontal RadRibbonbarButtons(with vertical orientation).

As these buttons are placed in two separate ribbonBarbuttons,therefore I can select two radio buttons simultaneously , one from each ribbonbarButton.

Please let me know how to keep the group of radiobuttons same, although are placed in different radribbonbarButton group.

Thanks in Advance!
Anjali

1 Answer, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 02 Nov 2012, 07:42 AM
Hello Santhosh,

Thank you for writing.

I assume that you want to have 8 radio buttons split in 2 groups and this 8 buttons to have behavior like they are in one group. If so, here is how you can do that:
private void Form1_Load(object sender, EventArgs e)
{
    this.radRadioButtonElement1.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement2.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement3.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement4.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement5.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement6.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement7.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);
    this.radRadioButtonElement8.ToggleStateChanged += new Telerik.WinControls.UI.StateChangedEventHandler(this.RadioButtons_ToggleStateChanged);   
}
 
private void RadioButtons_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
{
    if (sender is RadRadioButtonElement && args.ToggleState == ToggleState.On)
    {
        RadRadioButtonElement radioBtn = sender as RadRadioButtonElement;
        if (radRibbonBarButtonGroup1.Items.Contains(radioBtn))
        {
            foreach (RadRadioButtonElement item in radRibbonBarButtonGroup2.Items)
            {
                if (item.ToggleState == ToggleState.On)
                {
                    item.ToggleState = ToggleState.Off;
                }
            }
        }
        if (radRibbonBarButtonGroup2.Items.Contains(radioBtn))
        {
            foreach (RadRadioButtonElement item in radRibbonBarButtonGroup1.Items)
            {
                if (item.ToggleState == ToggleState.On)
                {
                    item.ToggleState = ToggleState.Off;
                }
            }
        }
        radioBtn.ToggleState = ToggleState.On;
        this.radLabel1.Text = radioBtn.Text + " is selected";
    }
}
Attached is a sample project that comprises the code above. 

Additionally, if you want to hide the borders of the button groups you can use the above code:
radRibbonBarButtonGroup1.ShowBorder = false;
radRibbonBarButtonGroup2.ShowBorder = false;

I hope this helps. Should you have any other questions, do not hesitate to contact us.

Regards,
Anton
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
RibbonBar
Asked by
Mahesh V
Top achievements
Rank 2
Answers by
Anton
Telerik team
Share this question
or