VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Control Array at designTime Posted by nfor_onlyme on 27 Dec 2006 at 2:14 AM
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.
Report
Re: Control Array at designTime Posted by PavlinII on 27 Dec 2006 at 9:47 AM
: 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 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

Pavlin II[/size]

Don't take life too seriously anyway you won't escape alive from it!





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.