簡體   English   中英

如何在 C# Windows 窗體應用程序中修復窗體大小而不讓用戶更改其大小?

[英]How can I fix the form size in a C# Windows Forms application and not to let user change its size?

如何在 C# Windows 窗體應用程序中修復窗體大小而不讓用戶更改其大小?

檢查一下:

// 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;

屬性 - > FormBorderStyle - > FixedSingle

如果找不到屬性工具。 轉到視圖 - >屬性窗口

我很確定這不是最好的方法,但您可以將MinimumSizeMaximimSize屬性設置為相同的值。 這將阻止它。

Maximize屬性設置為False

單擊“設計”窗口中的表單后,可以在“屬性”窗口中進行必要的更改。 要調整表單的Size ,請更改Size屬性的WidthHeight字段。 為了保持表單的大小不變,將值FixedSingle分配給FormBorderStyle屬性。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM