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

Check RadCheckBoxElement without raising event

3 Answers 62 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 29 Nov 2011, 09:01 AM
Hi,

I want to initialize ToggleState or Checked property of the RadCheckBoxElement, which I placed in the RibbonBar control.
Is there a chance to do this without raising the ToggleStateChanged event?

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Dec 2011, 05:10 PM
Hello Marco,

Thank you for the writing.

I would like to suggest subscribing to the event after the control is initialized, for example:

radCheckBoxElement1.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On
 
AddHandler radCheckBoxElement1.ToggleStateChanged, AddressOf ToggleStateChanged
 
Sub ToggleStateChanged(sender as object, args as StateChangedEventArgs)
 
End Sub

I hope this helps.

Kind regards,
Peter
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Marco
Top achievements
Rank 1
answered on 02 Dec 2011, 08:22 AM
Hello Peter,

thank you for your reply.
I made a fault, because in my logic I convert the RadItem, to the RadCheckBoxElement or the RadButtonElement, etc., with the as C# operator.
The RadCheckBoxElement inherits from the RadButtonElement, so the event was subscibed twice.
I corrected my logic like this example:

foreach (RadItem radItem in items)
{
    bool handled = false;
 
    RadRibbonBarGroup ribbonBarGroup = radItem as RadRibbonBarGroup;
    if (ribbonBarGroup != null && !handled)
    {
        this.InitializeRibbonBarItemsState(ribbonBarGroup.Items);
        handled = true;
    }
 
    RadRibbonBarButtonGroup ribbonBarButtonGroup = radItem as RadRibbonBarButtonGroup;
    if (ribbonBarButtonGroup != null && !handled)
    {
        this.InitializeRibbonBarItemsState(ribbonBarButtonGroup.Items);
        handled = true;
    }
 
    RadCheckBoxElement checkBoxElement = radItem as RadCheckBoxElement;
    if (checkBoxElement != null && !handled)
    {
        this.InitializeCheckBoxElement(checkBoxElement);
        handled = true;
    }
 
    RadDropDownListElement dropDownListElement = radItem as RadDropDownListElement;
    if (dropDownListElement != null && !handled)
    {
        this.InitializeRadDropDownListElement(dropDownListElement);
        handled = true;
    }
 
    RadButtonElement buttonElement = radItem as RadButtonElement;
    if (buttonElement != null && !handled)
    {
        this.InitializeButtonElement(buttonElement);
        handled = true;
    }
}

Best regards.
Marco
0
Peter
Telerik team
answered on 02 Dec 2011, 05:00 PM
Hello Marco,

I am happy to hear that you managed to get it working.

Do not hesitate to write me back if you have further questions.

Best wishes,
Peter
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
RibbonBar
Asked by
Marco
Top achievements
Rank 1
Answers by
Peter
Telerik team
Marco
Top achievements
Rank 1
Share this question
or