items in tabular fashion in RadRibbonbarButtons

2 posts, 0 answers
  1. Suresh G
    Suresh G avatar
    9 posts
    Member since:
    Mar 2012

    Posted 30 Oct 2012 Link to this post

    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
  2. Anton
    Admin
    Anton avatar
    167 posts

    Posted 02 Nov 2012 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top