TextBoxBase.SelectAll Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Selects all text in the text box.
public:
void SelectAll();
public void SelectAll ();
member this.SelectAll : unit -> unit
Public Sub SelectAll ()
Examples
The following code example uses TextBox, a derived class, to determine if any text is selected in the control. If no text is selected, a call is made to the SelectAll method before copying the contents of the control to the Clipboard. This example requires that a TextBox has been created named textBox1
.
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
Remarks
This method enables you to select all text within the control. You can use this method in conjunction with the Cut method, which requires text to be selected in the control, to cut the entire contents of the control and paste them into the Clipboard.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈