jj_30
asked on
Simple question about PictureBoxes
: Ok, well, I have a trial subscription, but I googled a bunch on this, and nothing that I found worked. Perhaps the experts exchange model is the best for solutions, as required by the workplace.
I am dynamically adding buttons to an inherited form class (the class inherits "form", is maximized, has a background and a picturebox on it to make it look nice ... as simple as it gets).... anyway, I am dynamically adding buttons, and the buttons always show behind the picturebox, even as I use bringToFront, and even if I do this AFTER adding to the control array (after me.controls.add).
I think I'm missing something very fundamental here, but I didn't plan on spending three hours trying to get a label on top of a picturebox, so I'm asking for help.
Thanks
I am dynamically adding buttons to an inherited form class (the class inherits "form", is maximized, has a background and a picturebox on it to make it look nice ... as simple as it gets).... anyway, I am dynamically adding buttons, and the buttons always show behind the picturebox, even as I use bringToFront, and even if I do this AFTER adding to the control array (after me.controls.add).
I think I'm missing something very fundamental here, but I didn't plan on spending three hours trying to get a label on top of a picturebox, so I'm asking for help.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This jumps out at me:
For i As Integer = 0 To Me.Controls.OfType(Of GlassButton).Count - 1
Me.Controls.Item(i).BringT oFront()
Next
The "i" value is simply going from 0 to Count -1...BUT the there is NO correlation between "i" and the corresponding returned controls position in the Items() collection:
Me.Controls.Item(i).BringT oFront() ' <----- it doesn't make sense to use "i" here
I think you actually wanted this:
For Each gb As GlassButton In Me.Controls.OfType(Of GlassButton)()
gb.BringToFront()
Next
For i As Integer = 0 To Me.Controls.OfType(Of GlassButton).Count - 1
Me.Controls.Item(i).BringT
Next
The "i" value is simply going from 0 to Count -1...BUT the there is NO correlation between "i" and the corresponding returned controls position in the Items() collection:
Me.Controls.Item(i).BringT
I think you actually wanted this:
For Each gb As GlassButton In Me.Controls.OfType(Of GlassButton)()
gb.BringToFront()
Next
ASKER
Why, yes ... it does help.
Thanks
Thanks
ASKER
Hm, the OfType enumeration doesn't seem to work like I thought. It's linq-related.
me.controls.oftype(of GlassButton) returns something that's hard to parse.
It has <>3__source, <>7__wrapa5, etc. ... Perhaps a little advanced for me today.
Thanks for your help though!
me.controls.oftype(of GlassButton) returns something that's hard to parse.
It has <>3__source, <>7__wrapa5, etc. ... Perhaps a little advanced for me today.
Thanks for your help though!
ASKER
Open in new window