问题描述
亲爱的所有人,
Win Form中有一个statusStrip组件,
There is a statusStrip component inside the Win Form,
如何以编程方式获取 statusStrip宽度限制Win Form最小宽度等于statusStrip宽度?
How to get the statusStrip width programmatically and limit the Win Form min width is equal to statusStrip width?
如果WinForm更改为Max size,则statusStrip将扩展为Win Form的宽度,同时将Win Form更改为min size ,它仅限于statusStrip的宽度。
That's if WinForm is changed to Max size, the statusStrip will extended to the width with Win Form, while change Win Form to min size, it is limited to the statusStrip's width.
因为可以在功能中更改statusStrip宽度,所以最好以编程方式限制Win Form大小。
Because the statusStrip width may be changed in the feature, it is better to limit the Win Form size programmatically.
谢谢。
谢谢和问候,
E-John
推荐答案
private void Form1_SizeChanged(object sender, EventArgs e)
{
txt_FormWidth.Text = this.Size.Width.ToString();
txt_FormHeight.Text = this.Size.Height.ToString();
txt_StatusStripWidth.Text = this.statusStrip1.Size.Width.ToString();
txt_StatusStripHeight.Text = this.statusStrip1.Size.Height.ToString();
}
如果您不使用StatusStrip.Dock = Dock.Bottom,请使用 StatusStrip_SizeChanged 的事件。
问候,
If you do not use StatusStrip.Dock = Dock.Bottom, please use event of StatusStrip_SizeChanged.
Regards,
这篇关于如何通过在Win Form中获取statusStrip的宽度来设置Win Form最小宽度? statusStrip dock属性设置为bottom。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!