简体   繁体   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 窗体应用程序中修复窗体大小而不让用户更改其大小?

Check this: 检查一下:

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

Try to set 尝试设置

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

Minimal settings to prevent resize events 用于防止调整大小事件的最小设置

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

Properties -> FormBorderStyle -> FixedSingle 属性 - > FormBorderStyle - > FixedSingle

if you can not find your Properties tool. 如果找不到属性工具。 Go to View -> Properties Window 转到视图 - >属性窗口

I'm pretty sure this isn't the BEST way, but you could set the MinimumSize and MaximimSize properties to the same value. 我很确定这不是最好的方法,但您可以将MinimumSizeMaximimSize属性设置为相同的值。 That will stop it. 这将阻止它。

Maximize属性设置为False

After clicking on the form in the Design window, necessary changes can be made in the Properties window.单击“设计”窗口中的表单后,可以在“属性”窗口中进行必要的更改。 To adjust the size of the form, the Width and Height fields of the Size property are changed.要调整表单的Size ,请更改Size属性的WidthHeight字段。 In order to keep the size of the form constant, the value FixedSingle is assigned to the FormBorderStyle property.为了保持表单的大小不变,将值FixedSingle分配给FormBorderStyle属性。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#和Windows Forms应用程序表单大小 - C# and Windows Forms application form size 如何通过调整大小来修复C#Windows窗体应用程序的大小 - How to fix the size of a C# Windows Form Application from resizing Windows Forms C# 应用程序 - 当用户为操作系统字体大小选择 125% 或 150% 时,设置表单控件的字体大小以适应屏幕? - Windows Forms C# application - Set font size of form controls to fit the screen when a user choose 125% or 150% for the OS font size? 当用户选择125%或150%的OS字体大小时,如何强制Windows窗体C#应用程序忽略? - How do I force a Windows Forms C# application to ignore when a user choose 125% or 150% for the OS font size? 如何在运行时通过 windows 表单 c# 中的按钮更改表单大小 - How to change form size at runtime by a button in windows form c# 如何在Windows Forms应用程序中更改所有屏幕的字体大小 - How can I change the font size of all the screens in a windows forms application C#Windows窗体:如何将backgroundimage大小匹配到窗体大小 - c# windows form: How to match backgroundimage size to form size 如何按子级更改Windows窗体中的父级大小? - How to change parent size in Windows forms by its child? C#Windows窗体如何使控件的位置和大小相对于其父容器相对恒定? - C# Windows Forms How to keep control's location and size relatively constant to its parent container? 为什么Windows窗体大小与C#中的设置不同? - Why is the windows form size different from its setting in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM