如何在C#Windows窗体应用程序中修复表单大小而不是让用户更改其大小?

odi*_*seh 36 .net c# size fixed winforms

如何在C#Windows窗体应用程序中修复表单大小而不是让用户更改其大小?

Pra*_*ana 66

检查一下:

// 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();
Run Code Online (Sandbox Code Playgroud)

  • 我认为这不会阻止您双击标题栏并全屏显示 (2认同)

小智 15

尝试设置

this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);
Run Code Online (Sandbox Code Playgroud)


小智 10

用于防止调整大小事件的最小设置

form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
Run Code Online (Sandbox Code Playgroud)


小智 7

属性 - > FormBorderStyle - > FixedSingle

如果找不到属性工具.转到视图 - >属性窗口


Pau*_*els 4

我很确定这不是最好的方法,但您可以将MinimumSizeMaximimSize属性设置为相同的值。那会阻止它。