1. 程式人生 > >Form(窗體)的FormBorderStyle屬性的不同效果

Form(窗體)的FormBorderStyle屬性的不同效果

設定窗體邊框可以通過設定窗體的FormBorderStyle屬性設定。屬性值可以通過列舉型別FormBorderStyle獲取,它的取值和意義如下表所示。

屬性 意義
FormBorderStyle.None 0 無邊框
FormBorderStyle.FixedSingle 1 固定的單行邊框
FormBorderStyle.Fixed3D 2 固定的三維樣式邊框
FormBorderStyle.FixedDialog 3 固定的對話方塊樣式的粗邊框
FormBorderStyle.Sizable 4 可調整大小的邊框
FormBorderStyle.FixedToolWindow 5 不可調整大小的工具視窗邊框
FormBorderStyle.SizableToolWindow 6 可調整大小的工具視窗邊框

總是記不住這幾個值是什麼意義(雖然能夠在設計器中觀察到大概的外觀),因此用下面一個方法遍歷一下:

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, } }