Event Handler on dynamic RadButtonElements

Thread is closed for posting
3 posts, 0 answers
  1. Karin
    Karin avatar
    6 posts
    Member since:
    Apr 2006

    Posted 17 Oct 2007 Link to this post


    I'm dynamically populating a RadPanelBar with a series of GroupElements and RadButtonElements. I'd like to know how I can add an onClick handler to each generated RadButtonElement so that I can get the dyncamically generated buttons to perform some function.

    I've done similar code with Menu Items which allow an OnClick eventHandler as a parameter when you add items to the Menu;

    ReportMenu.MenuItems(f).MenuItems(g).Add("Report X"), New System.EventHandler(AddressOf openReport_Click)) 

    Any ideas how I can get this all happening?

  2. Jordan
    Jordan avatar
    547 posts

    Posted 18 Oct 2007 Link to this post

    Hello Karin Hollands,

    You could try creating a RadButtonElement, subscribing for its Click event and then adding it to a group like:

    Public Sub New() 
        Dim button As RadButtonElement = New RadButtonElement("New button"
        AddHandler button.Click, AddressOf button_Click 
    End Sub 
    Private Sub button_Click(ByVal sender As ObjectByVal e As EventArgs) 
        MessageBox.Show((TryCast(sender, RadButtonElement)).Text) 
    End Sub 

    Hope that helps. Please contact us again if you have any additional questions.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Karin
    Karin avatar
    6 posts
    Member since:
    Apr 2006

    Posted 18 Oct 2007 Link to this post

    Yep, that works a treat. I figured it had to be something fairly simple that I was missing.
    Thanks Jordan
Back to Top