Check RadCheckBoxElement without raising event

4 posts, 0 answers
  1. Marco
    Marco avatar
    19 posts
    Member since:
    Oct 2011

    Posted 29 Nov 2011 Link to this post

    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?
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 01 Dec 2011 Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marco
    Marco avatar
    19 posts
    Member since:
    Oct 2011

    Posted 02 Dec 2011 Link to this post

    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
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 02 Dec 2011 Link to this post

    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.

Back to Top