I want to hide panel2 on a split container and have panel1 utilize the space. I was hoping setting Panel2Collapsed would do the trick, but no luck. Ideas?
This worked for me on a similar situation:
splitContainer1.Panel2Collapsed = true;
splitContainer1.Panel2.Hide();
I wanted the second panel to not be visible at all in some cases, so I implemented it this way.
在表单设计器Panel2Collapsed
属性设置为true
并以编程方式将它们按照您的需要工作(即Panel1占用所有空间)...所以必须有其他事情继续进行。
this.splitContainerControl1.Panel2.Hide();
this.splitContainerControl1.Panel2.Height = 0;
this.splitContainerControl1.IsSplitterFixed = true;
This worked for me.
splitContainer1.PanelVisibility = SplitPanelVisibility.Panel1
With Visual Studio 2017 it is a little more trick. This is what I got to work for me. MyControl is inside panel1.
'vb.net:
MySplitContainer.Panel2Collapsed = True
MySplitContainer.Panel2.Hide()
MySplitContainer.SplitterDistance = MySplitContainer.Height
MySplitContainer.Panel1.Anchor = AnchorStyles.Bottom
MyControl.Height = MySplitContainer.Height
'for C# just add a semi-colon onto the end of each line and it should work.
尝试设置panel2.Visible = false。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.