ToolStripTextBox.SelectionLength 屬性

定義

取得或設定 ToolStripTextBox 中選取的字元數。

public:
 property int SelectionLength { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int SelectionLength { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionLength : int with get, set
Public Property SelectionLength As Integer

屬性值

Int32

ToolStripTextBox 選取的字元數。

屬性

備註

您可以使用這個屬性來判斷文字方塊控制項中目前是否選取任何字元,然後再對選取的文字執行作業。 當屬性的值 SelectionLength 設定為大於控制項文字中字元數的值時,屬性的值 SelectionLength 會設定為控制項內的整個文字長度減去 SelectionStart 屬性的值, (如果為屬性指定任何值 SelectionStart ,則為屬性) 。

注意

您可以透過程式設計方式移動文字方塊內的插入號,方法是將 設定 SelectionStart 為要移動插入號的文字方塊內的位置,並將 屬性設定 SelectionLength 為零 (0) 。 文字方塊必須有焦點,才能移動插入號。

適用於

另請參閱