By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

Control Events

P: n/a
Is it possible to loop through events of a control to determine which events
are active? In other words I want to dynamically add controls that will be
clones of controls I have placed in form including any events.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi, after dynamically creating the control, you can use AddHandler to attach
a method to the control's event:

AddHandler MyControl.MyEvent, AddressOf MyEventHandler

Is this what you are looking for?

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Nathan Carroll" <th************@Bhutan.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
Is it possible to loop through events of a control to determine which events are active? In other words I want to dynamically add controls that will be
clones of controls I have placed in form including any events.

Nov 20 '05 #2

P: n/a
When I say 'ParentControl' I mean as a source not a container for the new
control. ie I have properties of my mother but she does not contain me, My
house is my container.

Well I intend to utilize that, but what i'd like is someway to clone the
control as a new control. for instance:
dim NewControl as new TextBox
dim c as control
For each c in me.panel.controls
if typeof c is Textbox
'create control NewControl
'1. 'set properties of newcontrol=properties of c 'via loop
or with
'2. 'Loop events of c and the add handlers to NewControls
events
me.Panel2.controls.add(NewControl)
end if
end if

I won't know if the control has any events. Would I be able to set all of
the events of the NewControl even if the 'ParentControl' shows no event?
Add handlers for each event of the controltype? Does that make any sense?

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:e3*************@TK2MSFTNGP11.phx.gbl...
Hi, after dynamically creating the control, you can use AddHandler to attach a method to the control's event:

AddHandler MyControl.MyEvent, AddressOf MyEventHandler

Is this what you are looking for?

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Nathan Carroll" <th************@Bhutan.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
Is it possible to loop through events of a control to determine which

events
are active? In other words I want to dynamically add controls that will be clones of controls I have placed in form including any events.


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.