Form(窗体)的FormBorderStyle属性的不同效果

本文固定链接: http://blog.xieyc.com/form-border-style/ | 小谢的小站


设置窗体边框可以通过设置窗体的FormBorderStyle属性设置。属性值可以通过枚举类型FormBorderStyle获取,它的取值和意义如下表所示。

属性意义
FormBorderStyle.None0无边框
FormBorderStyle.FixedSingle1固定的单行边框
FormBorderStyle.Fixed3D2固定的三维样式边框
FormBorderStyle.FixedDialog3固定的对话框样式的粗边框
FormBorderStyle.Sizable4可调整大小的边框
FormBorderStyle.FixedToolWindow5不可调整大小的工具窗口边框
FormBorderStyle.SizableToolWindow6可调整大小的工具窗口边框


总是记不住这几个值是什么意义(虽然能够在设计器中观察到大概的外观),因此用下面一个方法遍历一下:

1
2
3
4
5
6
7
8
private  void  btnChangeBorderStyle( object  sender, EventArgs e)
{
     if  ( this .FormBorderStyle == System.Windows.Forms.FormBorderStyle.SizableToolWindow)
         this .FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     else
         this .FormBorderStyle++;
    ((Button)sender).Text =  this .FormBorderStyle.ToString();
}

截图记录在此:

附:枚举源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace  System.Windows.Forms
{
// Summary:
//     Specifies the border styles for a form.
[ComVisible( true )]
public  enum  FormBorderStyle
{
// Summary:
//     No border.
None = 0,
//
// Summary:
//     A fixed, single-line border.
FixedSingle = 1,
//
// Summary:
//     A fixed, three-dimensional border.
Fixed3D = 2,
//
// Summary:
//     A thick, fixed dialog-style border.
FixedDialog = 3,
//
// Summary:
//     A resizable border.
Sizable = 4,
//
// Summary:
//     A tool window border that is not resizable. A tool window does not appear
//     in the taskbar or in the window that appears when the user presses ALT+TAB.
//     Although forms that specify System.Windows.Forms.FormBorderStyle.FixedToolWindow
//     typically are not shown in the taskbar, you must also ensure that the System.Windows.Forms.Form.ShowInTaskbar
//     property is set to false, since its default value is true.
FixedToolWindow = 5,
//
// Summary:
//     A resizable tool window border. A tool window does not appear in the taskbar
//     or in the window that appears when the user presses ALT+TAB.
SizableToolWindow = 6,
}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值