2011年3月9日 星期三

TextBox 控制項

移動游標到TextBox控制項內容開頭
tbTextBox.Select( 0, 0 )

移動游標到TextBox控制項內容結尾
tbTextBox.Select( tbTextBox.Text.Length, 0 )

在 TextBox 控制項中設定焦點
tbTextBox.Focus()

偵測 TextBox 中的文字何時變更
使用TextChanged事件

設定TextBox輸入文字的長度
使用MaxLength屬設定   例如 : tbTextBox.MaxLength = 10

設定TextBox內文字顯示的位置
使用TextAlign屬性設定  例如 : tbTextBox.TextAlign =
HorizontalAlignment.Left        靠左對齊
HorizontalAlignment.Center    置中
HorizontalAlignment.Right      靠右對齊