TextBoxBase.SelectAll 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
選取文字框中的所有文字。
public:
void SelectAll();
public void SelectAll();
member this.SelectAll : unit -> unit
Public Sub SelectAll ()
範例
以下程式碼範例使用 TextBox,一個派生類別,來判斷控制項中是否選取任何文字。 若未選取文字,則先 SelectAll 呼叫該方法,然後將控制項內容複製至 剪貼簿。 此範例要求已建立名為 TextBoxtextBox1的 。
public:
void CopyAllMyText()
{
// Determine if any text is selected in the TextBox control.
if ( textBox1->SelectionLength == 0 )
{
// Select all text in the text box.
textBox1->SelectAll();
}
// Copy the contents of the control to the Clipboard.
textBox1->Copy();
}
public void CopyAllMyText()
{
// Determine if any text is selected in the TextBox control.
if(textBox1.SelectionLength == 0)
// Select all text in the text box.
textBox1.SelectAll();
// Copy the contents of the control to the Clipboard.
textBox1.Copy();
}
Public Sub CopyAllMyText()
' Determine if any text is selected in the TextBox control.
If textBox1.SelectionLength = 0 Then
' Select all text in the text box.
textBox1.SelectAll()
End If
' Copy the contents of the control to the Clipboard.
textBox1.Copy()
End Sub
備註
此方法允許您選擇控制範圍內的所有文字。 你可以搭配這個方法,因為 Cut 這個方法需要在控制項中選取文字,然後剪下控制項的全部內容並貼到 夾板中。