天天看點

C#程式設計-48:文本控件複習筆記

1、文本控件

(1)标簽Label

(2)按鈕Button

(3)文本框TextBox

(4)有格式文本RichTextBox

2、Label

System.Windows.Forms.Label

設定:屬性面闆,代碼

Size指整個窗體外邊框的大小

ClientSize指窗體内邊框大小

Random(min,max)能取下界,不能取上界

3、Button

System.Windows.Forms.Button

要想關閉所有的窗體,我們隻需要關閉主窗體即可

Form1 fm = new Form1();

fm.Close();

此處我們又建立了一個form執行個體,并非已經打開的form1

解決問題:擷取目前打開的執行個體

實作方法:靜态存儲,全局共享

4、TextBox

System.Windows.Forms.TextBox

Multiline多行顯示

CharacterCasing字母大小寫

MaxLength最大字元長度,機關char

AcceptsReturn接受回車,預設True,False多行顯示配合AcceptButton

PassWordChar密碼掩蓋符

ReadOnly隻讀

ScrollBars滾動條

WordWrap控制換行,預設True

Text文本内容

6、RichTextBox

具有格式特征

繼續閱讀