今天用VS08(.NET 3.5)编的WinForm,出了个奇怪的问题,请高人求教。
就是一个Form里放了一个SplitContainer控件,SplitContainer里还有若干控件。然后在Form的SizeChanged事件加入如下代码:
[code]
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.Font = new Font("宋体", this.Width / 50);
...
}
[/code]
会报错:“0”的值对于“SplitterWidth”无效。“SplitterWidth”必须大于或等于 1。(ArgumentOutOfRangeException)但改成
[code]
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.splitContainer1.Font = new Font("宋体", this.Width / 50);
...
}
[/code]
就没有问题。很诡异,我修改窗体的Font怎么会影响到SplitContainer的SplitterWidth属性?
就是一个Form里放了一个SplitContainer控件,SplitContainer里还有若干控件。然后在Form的SizeChanged事件加入如下代码:
[code]
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.Font = new Font("宋体", this.Width / 50);
...
}
[/code]
会报错:“0”的值对于“SplitterWidth”无效。“SplitterWidth”必须大于或等于 1。(ArgumentOutOfRangeException)但改成
[code]
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.splitContainer1.Font = new Font("宋体", this.Width / 50);
...
}
[/code]
就没有问题。很诡异,我修改窗体的Font怎么会影响到SplitContainer的SplitterWidth属性?
private void Form1_SizeChanged(object sender, EventArgs e)
{
this.Font = new Font("宋体", this.Width / 50);
}//ArgumentOutOfRangeExceptionprivate void Form1_SizeChanged(object sender, EventArgs e)
{
this.Font = new Font("宋体", 9);
}//OKprivate void Form1_SizeChanged(object sender, EventArgs e)
{
this.splitContainer1.Font = new Font("宋体", this.Width / 50);
}//OK求教了。