Adding Controls To Form Through Code

StreaksAthlete

Newcomer
Joined
Aug 14, 2005
Messages
1
i am using this code to add a picturebox to my form and perform a drag drop operation. But when i run the form, nothing shows up.
I need some help, PLEASE.


Code:
Dim i as New Picturebox
Me.Controls.Add(i)
i.Visible = True
i.Image = imgFloor.Image'Another Picture on my form"
i.Left = 10
i.Top = 10
 
Visual Basic:
dim i as picturebox
i = new picturebox 'can someone  tell me what the difference between that and dim i as new picturebox is?
i.visible = true
i.image = imgfloor.image
i.left = 10
i.top = 10
'now you add it
me.controls.add(i)
'<shrug> just in case
me.refresh

I think that will do it. You were adding and then changing i's properties. Once you've added, the form has its own copy of i, you can change i all you want, but it won't make a difference.
 
thenerd said:
Visual Basic:
dim i as picturebox
i = new picturebox 'can someone tell me what the difference between that and dim i as new picturebox is?
isn't
Visual Basic:
dim i as picturebox = new picturebox


the equivalent of

Visual Basic:
[indent]

dim i as picturebox i = new picturebox
[/indent]



I don't think you can do

Visual Basic:
dim i as new picturebox

in vb.not, can you?


 
the vb formatting screwd up. it should have read:

isn't
Visual Basic:
dim i as picturebox = new picturebox


the equivalent of

Visual Basic:
[indent]dim i as picturebox
 
i = new picturebox
[/indent]



I don't think you can do

Visual Basic:
dim i as new picturebox







in vb.not, can you?








 
Back
Top