看我的情况是,
我在forms (toplevel=false)
内打开了多个panel
。在运行时期间,forms
内部panel
打开的所有dock filled
都将是brought to front
和form
。在这种情况下我需要的是,如何在panel
上选择最顶层的控件(form
)。最重要的控制意味着控制(z-order
)具有更大的 panel.controls(0)
。
我目前正在假设使用此代码,
{{1}}
任何机构都可以告诉我,上面的代码片段是正确的还是dot net中可用的任何替代语法来实现这一点。?
答案 0 :(得分:5)
答案 1 :(得分:1)
我没有看到任何其他循环遍历每个Control的解决方案,看看最顶层的是什么。 类似的东西:
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