Control Events

N

Nathan Carroll

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.
 
T

Tom Spink

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
 
N

Nathan Carroll

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top