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

RadToolBar Dynamically Assign Event Handler

2 Answers 113 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Steve Keating
Top achievements
Rank 1
Steve Keating asked on 29 Jul 2008, 09:54 PM
Hi All,

I'm developing a UI framework and have an event handler defined in an interface so that all User controls / content pages can implement functionality through standard defined methods (interface definition). 

I have a RadToolbar in my ui framework and need to assign its event handler for the button click event in code behind so that each user control can re-define the inner workings of the event based on which buttons have been dynamically added to the toolbar by that page / user control. 

I can get a reference to the toolbar and dynamically add buttons to it no problem, However when i go to hook up an event handler vs 08 complains. 
Using the toolbar.ButtonClick += new EventHandler(addresof Event_Handler_Method)  doesn't seem to work. 

Anyone have any ideas as to how I can accomplish this programmatically or another syntax I can use that works with RadToolBar?  Or am I missing something and doing this entirely incorrectly?

Thanks,
SK

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 30 Jul 2008, 07:55 AM
Hi Steve Keating,

What is the programming language you are using? In VB.NET you should use the AddHandler method. In C# you can use the "+=" syntax however you don't need an "addressof". Visual Studio should automatically generate the event handler for you.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve Keating
Top achievements
Rank 1
answered on 30 Jul 2008, 04:47 PM
Telerik,

Thanks!  Apparently I was mixing my language syntaxes.  I've been going back and forth between C# and VB a lot lately.  Using the AddHandler method fixed everything.  Thanks so much.  You guys have been great so far.  Always very quick response times and very useful answers!

Thanks,
SK
Tags
ToolBar
Asked by
Steve Keating
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Steve Keating
Top achievements
Rank 1
Share this question
or