Control Array at designTime - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Control Array at designTime

nfor_onlymenfor_onlyme Posts: 1Member
Hi all.
i Want to create a control array at designtime (vb.net).I did it through this codings
'Declare
Dim Label(2) as label
'then Inside form load I write the following codes
label(0)=label1
label(1)=label2

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.

Comments

  • PavlinIIPavlinII Posts: 404Member
    : Hi all.
    : i Want to create a control array at designtime (vb.net).I did it through this codings
    : 'Declare
    : Dim Label(2) as label
    : 'then Inside form load I write the following codes
    : label(0)=label1
    : label(1)=label2
    :
    : 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.
    :
    Hi,
    is there a [b]very[/b] 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

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.