Event Handler on dynamic RadButtonElements

3 posts, 0 answers
  1. Jargo
    Jargo avatar
    6 posts
    Member since:
    Apr 2006

    Posted 17 Oct 2007 Link to this post

    Hi,

    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?

    Cheers,
    Karin
  2. Jordan
    Admin
    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() 
        InitializeComponent() 
     
        Dim button As RadButtonElement = New RadButtonElement("New button"
        AddHandler button.Click, AddressOf button_Click 
     
        Me.radPanelBarGroupElement1.Items.Add(button) 
    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.

    Regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jargo
    Jargo 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