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

Event Handler on dynamic RadButtonElements

2 Answers 79 Views
Panelbar (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Karin
Top achievements
Rank 1
Karin asked on 17 Oct 2007, 08:05 AM
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 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 18 Oct 2007, 07:56 AM
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
0
Karin
Top achievements
Rank 1
answered on 19 Oct 2007, 02:35 AM
Yep, that works a treat. I figured it had to be something fairly simple that I was missing.
Thanks Jordan
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
Karin
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Karin
Top achievements
Rank 1
Share this question
or