Creating control then adding events

  • Thread starter Thread starter Timothy Taylor
  • Start date Start date
T

Timothy Taylor

Hello,

I would really like to take advantage of the object orientation in VB.NET...

This is what i need to do...

I want to be able to create a control during runtime, i can do that, but
there's a twist. I want to then tell that control to have a click event. I
want to tell the control that when it's clicked, to go to a certain sub or
function. I've seen code that might do this before, but i have lost the
code. Please, any help is great. I really need to do this.

Any ideas? THANKS!


-Tim
 
I am not sure I understand your question

here is 2 possible answer:
1. System.Reflection.Emit is not supported by the compact framework, so you
can't create new Class.

2. you mean you want to create a new Button() ? and myButton.Click = new
EventHandler(AClicHandler) ? do you ?

where is the difficulty ?
this could could as well be in an event handler than in the
'InitializeComponent' method ...
an advice, looks at what code the designer generate, and copy/paste it into
your event handler.....
 
Yes, #2 is what i am tring to do. I tried your code and it gives me errors!
Please give me detail
InitializeComponent doesn't show you it's eventhandlers
 
yep, sorry it was C# code, beside it was "+= new EventHandler(..." (instead
of '=')

well I try a new visual basic project myself to see what happened....
mmhh... have you think to try C# ?

mmhh....
look at the .NET documentation... I found it !
ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconeventsoverview.htm
 
If what you need can't be staisified by static logic (such as initialize
components where you init and wire controls up front) then you can look at
System.Reflection for dynamically creating objects and invoking methods on
them etc.

I would think, what you need can probably be achieved via static logic but
it's hard to say as I don't know the exact scenario you are after.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top