繁体   English   中英

更改 Winforms 用户控件中的 Dock 属性

[英]Changing the Dock property in a Winforms user control

我正在尝试创建一个按钮,该按钮将隐藏我停靠在用户控件中心的面板。

我的表格布局如下:

toolStrip1 (docked to top)
topPanel (docked to fill)
bottomPanel (docked to bottom)

我有以下代码:

Private Sub ShowHideTopPanel()
    If topPanel.Visible Then
        topPanel.Visible = False
        bottomPanel.Dock = DockStyle.Fill
    Else
        topPanel.Visible = True
        bottomPanel.Dock = DockStyle.Bottom
    End If
End Sub

这在一定程度上有效。 但是,当bottomPanel设置为 Fill 时,它似乎会填充整个控件,而不仅仅是toolStrip1 谁能告诉我为什么会发生这种情况,以及如何纠正它?

您的控件的 z-index 导致了这种行为。 尝试使用[Control].BringToFront()[Control].SendToBack()方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM