ComboBox.Select(Int32, Int32) 方法

定義

ComboBox 的可編輯部分中選取某個範圍的文字。Selects a range of text in the editable portion of the ComboBox.

public:
 void Select(int start, int length);
public void Select (int start, int length);
override this.Select : int * int -> unit
Public Sub Select (start As Integer, length As Integer)

參數

start
Int32

文字方塊中目前的文字選取範圍中第一個字元的位置。The position of the first character in the current text selection within the text box.

length
Int32

要選取的字元數。The number of characters to select.

例外狀況

start 小於零。The start is less than zero.

-或--or- start 加上 length 小於零。start plus length is less than zero.

備註

如果您想要將開始位置設定為控制項文字中的第一個字元,請將 start 參數設定為零。If you want to set the start position to the first character in the control's text, set the start parameter to zero. 您可以使用這個方法來選取文字的子字串,例如搜尋控制項的文字並取代資訊時。You can use this method to select a substring of text, such as when searching through the text of the control and replacing information.

注意

SelectionStart 會傳回目前選取範圍的較小值。SelectionStart returns the lower value of the current selection. 例如,Select(10, -4) 會從字元位置6到字元位置10選取文字。For example, Select(10, -4) selects the text from character position 6 through character position 10. 如果您現在取得 SelectionStart 值,則會是6,而不是10。If you now get the SelectionStart value, it will be 6 rather than 10.

適用於

另請參閱