Hi, I load many of the picturebox (I named them pic) with the index 0 to 10 (pic(0) to pic(10)) on top of my main (biggest) picturebox.

My problem is, pic(1) will always be on top of pic(2). pic(6) will always be at the bottom of pic(5) and so on....

How can I actually set this, so pic(6) will be on top of pic(5) in some specific case?

thanks.

Dani AI

Generated

uploaded an array of overlapping PictureBox controls and noticed the stacking follows creation/index order. pointed toward changing the controls' stack; the practical fixes depend on which Visual Basic you are using and on whether the controls share the same parent container.

For WinForms (VB.NET) the two easiest runtime options are BringToFront() or setting the control collection index. Example:

' VB.NET (WinForms)
pic(6).BringToFront()

' Or set explicit z-order (0 = topmost)
Me.Controls.SetChildIndex(pic(6), 0)

Microsoft docs: Control.BringToFront and ControlCollection.SetChildIndex.

In classic VB use the control's z-order method to move a PictureBox up or down the stacking order. A key gotcha in both environments is parentage: z-order only affects sibling controls. If one PictureBox is inside another container (another PictureBox, Panel, GroupBox, etc.) it cannot be drawn above a control in a different container without reparenting it.

If the goal is simply to composite images (rather than manipulate many separate controls), it is often cleaner and faster to draw the images onto a single bitmap and show that—this avoids transparency quirks, flicker, and runtime reordering complexity. When reordering many controls at runtime, use SuspendLayout/ResumeLayout or double buffering to reduce flicker.

Recommended Answers

All 2 Replies

check out the ZOrder Property or you could play around with the Visible Property...

Good Luck

awesome. thanks as always vb5prgrmr :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.