: Hi all.
: i Want to create a control array at designtime (vb.net).I did it through this codings
: Dim Label(2) as label
: 'then Inside form load I write the following codes
: Now problem is a common event handler to these controls
: Can Any body Help in crating control array at designtime in vb.net and handling of events.
is there a very good reason for using array?
I'd prefere to use that controls are in common container (if they are), or use arraylist, collection, or something generic (Like Generic.List(Of Label) etc).
But if you need add handler, there are two possibilites:
1) You have you label1 declaread as WithEvents... Then you can use
Procedure SomeName(Sender As Object, e as EventArgs) Handles Label1.YourEventName
where EventArgs can be more specific type (depending on current event signature) and YourEventName is concrete name, .Click for example.
2) You do not have WithEvents delcaration and you want to add handler runtime. In this case, use AddHandler statement
AddHanler label1.YourEventName, AddressOf SomeName
where SomeName is name of Sub that will handle YourEventName event of label1
Hope this helps
Don't take life too seriously anyway you won't escape alive from it!