我如何在C# Windows Forms 应用程序中固定表单大小,防止用户更改其大小?
看这个:
// Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = false;
// Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen;
// Display the form as a modal dialog box.
form1.ShowDialog();
尝试进行设置
this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);
最小设置以防止调整大小事件
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
属性 -> 窗体边框样式 -> 固定单个
如果您找不到“属性”工具,请转到“视图” -> “属性窗口”
我相信这不是最好的方法,但你可以将 MinimumSize
和 MaximimSize
属性设置为相同的值。这样就可以阻止它了。
MaximizeBox
属性”吗? - Peter Mortensen