See my case is,
I am opening more than one forms (toplevel=false)
inside a panel
. All the forms
opened inside that panel
will be dock filled
and brought to front
during runtime. and my need in this situation is, how can i select the top most control(form
) on that panel
. Top most control means control(form
) which is having greater z-order
.
I am currently using this code by assumption,
panel.controls(0)
Can any body tell me, whether the above snippet is right or any alternate syntax available in dot net to achieve that.?
According to the MSDN:
The control with an index value of zero is at the top of the z-order, and higher numbers are closer to the bottom.
Therefore, I'd say your assumption was correct. Controls(0)
will always be the top-most control. The only concern would be whether or not it is visible.
I don't see any other solution of looping through each Control and see what's the topmost one. Something like:
Dim TopMostControl As Control = panel.Controls(0) 'Check if there are any control
For Each Control As Control In panel.Controls
If panel.Controls.GetChildIndex(Control) < panel.Controls.GetChildIndex(TopMostControl) Then
TopMostControl = Control
End If
Next
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