我想尝试这样一个很酷的小图像

对于我的拆分容器拖动按钮.
我在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);
}
Run Code Online (Sandbox Code Playgroud)
它确实绘制了我想要的图像,问题是高度总是4像素.在设计器中,我将SplitterWidth设置为15,但在运行时它始终保持为4.因此,实际上只显示4个像素.
Lar*_*ech 10
是的,根据你的评论,SplitterPanel内部a TableLayoutPanel确实使运行时忘记了SplitterWidth设置,所以我确实复制了问题. TableLayoutPanels是奇怪的生物.
不幸的是,明显的解决方法是:
public Form1() {
InitializeComponent();
splitContainer1.SplitterWidth = 15;
}
Run Code Online (Sandbox Code Playgroud)