Top level search (z-order) in the panel

See my case

I open more than one forms (toplevel=false)inside panel. All formsopen inside that panelwill dock filledand brought to frontat runtime. and my need for this situation is how I can select the topmost control ( form) on this panel. The greatest management controls ( form), which has more z-order.

I am currently using this code under the assumption

 panel.controls(0)

Can someone tell me if the above snippet or some alternative syntax available on the dot network is correctly specified to achieve this?

+5
source share
2 answers

MSDN:

z-, .

, . Controls(0) . , .

+5

, . - :

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
+1

All Articles