Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

c#窗体大小不允许调整的属性

作者:妖孽少年   发布日期:2025-11-04   浏览:68

// 设置窗体大小不允许调整的属性

using System;
using System.Windows.Forms;

namespace FixedSizeFormExample
{
    public class FixedSizeForm : Form
    {
        public FixedSizeForm()
        {
            // 禁用窗体的调整大小功能
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            // 或者使用以下属性,效果类似
            // this.FormBorderStyle = FormBorderStyle.Fixed3D;
            // this.FormBorderStyle = FormBorderStyle.FixedDialog;

            // 禁用最大化按钮
            this.MaximizeBox = false;

            // 设置窗体的初始大小
            this.Width = 800;
            this.Height = 600;

            // 可以添加其他控件和初始化代码
        }

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FixedSizeForm());
        }
    }
}

解释说明:

  1. FormBorderStyle.FixedSingle:设置窗体的边框样式为固定单线边框,这样用户无法调整窗体的大小。
  2. MaximizeBox = false:禁用最大化按钮,防止用户通过最大化按钮来改变窗体大小。
  3. WidthHeight:设置窗体的初始宽度和高度。用户无法调整窗体大小,因此这些尺寸是固定的。

如果你需要进一步的自定义或有其他问题,请告诉我!

上一篇:c# byte转int

下一篇:c# 获取当前路径

大家都在看

c# 二进制

c# datatable group by

c# tcp client

c# type.gettype

c# sqlconnection

c# string.format 小数位数

.net和c#

c#获取系统时间

c#游戏开发

c#网络编程

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站