我想放一张像这样很酷的小图
对于我的拆分容器拖动按钮。
我在 OnPaint 事件中执行以下操作
private void splitContainer1_Paint(object sender, PaintEventArgs e)
{
var control = sender as SplitContainer;
e.Graphics.DrawImage("...".Properties.Resources.divider, control.SplitterRectangle, 0, 0, 1040, 50, GraphicsUnit.Pixel);
}
它确实按照我的意愿绘制图像,问题是高度始终为 4 像素。 在设计器中,我将 SplitterWidth 设置为 15,但在运行时它始终保持在 4。因此,实际上只显示 4 个像素。
最佳答案
是的,根据您的评论,将 SplitterPanel
放在 TableLayoutPanel
中确实会使运行时忘记 SplitterWidth
设置,所以我确实重复了这个问题。 TableLayoutPanels
是一种奇怪的生物。
不幸的是,明显的解决方法:
public Form1() {
InitializeComponent();
splitContainer1.SplitterWidth = 15;
}
关于c# - Windows.Forms SplitContainer.SplitterWidth 不会在运行时保持设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8814412/