Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re: Responding to events created by dynamic controls added to a form


Message #1 by zane.gers@a... on Fri, 26 Apr 2002 15:10:54 +0100
Hi!

I did something like that a lot of time ago (don't remember exactly, but I 
think it was about 10 years ago!). I was using VB3, brand new shipped FIRST 
working version... and of course we didn't have anything like WithEvents. So I 
prepared a list of all the controls the user could use in my "form", and 
dragged one in the "template form". Made each one of them the element 0 of a 
control array, and set visible to false.
Basically, each new control was cloned from that one, already present on the 
form. The events were already there, and were working (naturally) using the 
Index parameter, due to the control array structure. So basically the only one 
thing I had to do was to identify the Index of the control (something I was 
storing in the Tag property of the element), and use it in the Event procedure. 
It worked! Since then, I never had to do that again. But if it worked for me in 
VB3...

Hope these hints can help. Let me know!

    Claudio de Biasio
      Team 97 S.r.l.


Quoting Zane Gers <zane.gers@a...>:

> I have a challenging problem which I hope you will be able to provide
> me
> with some key pointers as to how I can solve it? I am currently using
> VB6 
> to
> design a workflow grid that allows you to drag and drop toolbox items
> onto
> it. Now here is the catch. I would like to be able to dynamically
> (runtime) add controls to the form and be able to respond to the click 
> event
> for each control added at runtime. I am not sure whether this can be
> done. 
> I
> have found an article on the microsoft website that shows you how to 
> respond
> to adding 1 control to the form and responding dynamically. Now each
> time I
> add a control using the withevents keyword only the latest control
> added,
> that I click on responds to the event raised and none of the previous
> dynamically added controls respond to any events. It makes sense but
> don't
> know how to work around this. Do you know how I can solve this problem?
> 
> Please could you email me if any daring forward problem solvers come up
> 
> with a recommended solution
> 
> Thanks
> Zane Gers
> E-Mail : zane.gers@a...
> +xxx-xx-xxx-xxxx
> 

  Return to Index