2010-05-26 21 views
32

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

+1

哦,我得到它通過改變窗體的FormBorderStyle屬性.... – odiseh 2010-05-26 06:33:13

+1

不要忘記標記答案爲接受,如果它適用於你...... – 2012-08-02 12:03:44

+0

@odiseh我偶然發現了這一點,我看到你仍然沒有接受答案。請掩蓋一個答案已被接受 - 我確定在答案中提供了一個工作解決方案 – Breeze 2015-07-31 12:21:15

回答

2

我很確定這不是最好的方法,但是您可以將Minimum和Maximim大小屬性設置爲相同的值。這將阻止它。

56

入住這

// 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(); 
+0

對我來說這是很大的幫助。謝謝。 – 2011-08-15 02:47:43

+0

我不認爲這會阻止你雙擊標題欄,它會全屏 – Tizz 2012-02-16 22:11:51

+0

@Tizz我通過設計師改變了以上的事情,它的工作。雙擊沒有最大化它。我正在使用VS-2010 – prabhakaran 2012-08-28 11:31:53

13

嘗試設置

this.MinimumSize = new Size(140, 480); 
this.MaximumSize = new Size(140, 480); 
4

屬性 - > FormBorderStyle - > FixedSingle

,如果你不能找到你的屬性工具。轉到查看 - >屬性窗口

7

最小設置,以防止調整大小事件

form1.FormBorderStyle = FormBorderStyle.FixedDialog; 
form1.MaximizeBox = false; 
0

SET最大化性能使假

+0

「最大化的財產」?你的意思是「MaximizeBox屬性」嗎? – 2018-03-04 22:19:54

相關問題