I have an old system here, that loads user controls into a type of panel, then when a user clicks on a menu item, they find the control, then they call the BringToFront method on the control, making it the visible user control in the panel.
I need to know how to get the current Front control in the panel ?
kind regards
I think you are looking for GetChildIndex, this will give you the value of the z-oder of the control. So you can test this value for each child control in the current form controls collections, then:
The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.
Something like:
foreach (Control x in parent.Controls)
{
if(parent.Controls.GetChildIndex(x) == 0)
{
//x is the front most control
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With