TextBoxBase.SelectAll Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Memilih semua teks dalam kotak teks.
public:
void SelectAll();
public void SelectAll();
member this.SelectAll : unit -> unit
Public Sub SelectAll ()
Contoh
Contoh kode berikut menggunakan TextBox, kelas turunan, untuk menentukan apakah ada teks yang dipilih dalam kontrol. Jika tidak ada teks yang dipilih, panggilan dilakukan ke SelectAll metode sebelum menyalin konten kontrol ke Clipboard. Contoh ini mengharuskan telah TextBox dibuat bernama 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
Keterangan
Metode ini memungkinkan Anda memilih semua teks dalam kontrol. Anda dapat menggunakan metode ini bersama dengan Cut metode , yang mengharuskan teks dipilih dalam kontrol, untuk memotong seluruh konten kontrol dan menempelkannya ke Clipboard.