49

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

4

7 回答 7

81

检查这个:

// 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();
于 2010-05-26T06:37:59.113 回答
19

尝试设置

this.MinimumSize = new Size(140, 480);
this.MaximumSize = new Size(140, 480);
于 2012-11-29T11:40:59.147 回答
12

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

form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
于 2014-01-11T00:51:12.537 回答
10

属性 -> FormBorderStyle -> FixedSingle

如果您找不到您的属性工具。转到查看-> 属性窗口

于 2013-12-23T23:14:29.783 回答
4

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

于 2010-05-26T06:34:31.650 回答
1

在“设计”窗口中单击表单后,可以在“属性”窗口中进行必要的更改。要调整表单的大小,属性的WidthHeight字段Size会发生变化。为了保持表单的大小不变,将值FixedSingle分配给FormBorderStyle属性。

在此处输入图像描述

另外,您应该通过编辑窗口样式来防止屏幕放大;该MaximizeBox属性必须设置为false

在此处输入图像描述

由于通过属性窗口所做的更改而运行表单时,它的大小保持固定。

在此处输入图像描述

于 2022-01-01T20:06:41.730 回答
0

Maximize属性设置为False

于 2016-06-16T08:11:15.690 回答