Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Creating objects during run-time (http://www.go4expert.com/forums/creating-objects-run-time-t1017/)

djvargas 16Jul2006 21:18

Creating objects during run-time
 
I need some help with creating objects while the program is running.

I've noticed that when i am not running the program, when I drag(create) an object on the form, the program automatically makes some code in the "Windows Form Generated Code" region, that resembles "Friend WithEvents ObjectName bla bla bla" among other code below it.

I need a way to click a button and have a NEW picturebox appear in the form, and at the same time, add all that code to the Windows Form Generated Code. Is there a way to do this?

Thanks.

shabbir 17Jul2006 10:42

Re: Creating objects during run-time
 
You have to create an object of the picture box specifying all the properties and it will be placed on the form. Something like

Dim x as new PictureBox
then specify the left,top .... all the prop of x and it should be fine. If you want to add the events you can do that by making a dummy PictureBox and create an object of type picture box.

djvargas 18Jul2006 02:07

Re: Creating objects during run-time
 
I did what you said, but I still don't see a picturebox appearing on the form when I click the button where I have

dim x as new PictureBox
x.top = ...
and the rest of the properties

and nothing seems to happen.

shabbir 18Jul2006 23:41

Re: Creating objects during run-time
 
Here is a link for your problem.
How To Dynamically Add Controls to a Form with Visual Basic 6.0


All times are GMT +5.5. The time now is 03:59.