dynamically add controls

  • Thread starter Thread starter Snuyt
  • Start date Start date
S

Snuyt

Hello,


I want to add some PictureBoxes to a panel in my form. Therefore, I use:

Dim p As New PictureBox()
p.Image = New Bitmap("pic.bmp")
p.SetBounds(10, 10, 50, 50)
Panel.Controls.Add(p)


This works quite well, except for this thing : the pictureboxes that are
added, appear below each other. So, if I first add A, then B, B appears
below A. Can anyone tell me what to set to let B appear above A ? I've
tried A.bringToFront(), but that doesn't work.

thx
Snuyt
 
just delete the previous image...
Panel.Controls.Clear()
Panel.Controls.Remove()
Panel.Controls.RemoveAt()
 
* Snuyt said:
I want to add some PictureBoxes to a panel in my form. Therefore, I use:

Dim p As New PictureBox()
p.Image = New Bitmap("pic.bmp")
p.SetBounds(10, 10, 50, 50)
Panel.Controls.Add(p)


This works quite well, except for this thing : the pictureboxes that
are added, appear below each other. So, if I first add A, then B, B
appears below A. Can anyone tell me what to set to let B appear above
A ? I've tried A.bringToFront(), but that doesn't work.

You will have to call 'B.BringToFront'.
 
Back
Top