TextBoxBase.Select(Int32, Int32) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Metin kutusunda bir metin aralığı seçer.
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)
Parametreler
- start
- Int32
Metin kutusunun içindeki geçerli metin seçimindeki ilk karakterin konumu.
- length
- Int32
Seçecek karakter sayısı.
Özel durumlar
parametresinin start değeri sıfırdan küçüktür.
Örnekler
Aşağıdaki kod örneği, denetimin içeriğini "fox" sözcüğünün örneğine göre aramak için türetilmiş bir sınıfı kullanır TextBox. Kod bulunursa, yöntemini kullanarak Select denetimdeki sözcüğü seçer. Bu örnek, adlandırılmış bir TextBox adın textBox1 oluşturulmasını ve özelliğinin "Hızlı kahverengi tilki tembel köpeğin üzerinden atlar" cümlesini içermesini Text gerektirir.
public:
void SelectMyString()
{
// Create a string to search for the word "fox".
String^ searchString = "fox";
// Determine the starting location of the word "fox".
int index = textBox1->Text->IndexOf( searchString, 16, 3 );
// Determine if the word has been found and select it if it was.
if ( index != -1 )
{
// Select the string using the index and the length of the string.
textBox1->Select( index,searchString->Length );
}
}
public void SelectMyString()
{
// Create a string to search for the word "fox".
String searchString = "fox";
// Determine the starting location of the word "fox".
int index = textBox1.Text.IndexOf(searchString, 16, 3);
// Determine if the word has been found and select it if it was.
if (index != -1)
{
// Select the string using the index and the length of the string.
textBox1.Select(index, searchString.Length);
}
}
Public Sub SelectMyString()
' Create a string to search for the word "fox".
Dim searchString As String = "fox"
' Determine the starting location of the word "fox".
Dim index As Integer = textBox1.Text.IndexOf(searchString, 16, 3)
' Determine if the word has been found and select it if it was.
If index <> - 1 Then
' Select the string using the index and the length of the string.
textBox1.Select(index, searchString.Length)
End If
End Sub
Açıklamalar
Başlangıç konumunu denetimin metnindeki ilk karaktere ayarlamak istiyorsanız, parametresini start 0 olarak ayarlayın. Denetimin metninde arama yapma ve bilgileri değiştirme gibi bir metin alt dizesi seçmek için bu yöntemi kullanabilirsiniz.
Uyarı
Parametreyi, giriş işaretinin taşınmasını ve parametresini sıfır (0) değerine ayarlamasını istediğiniz metin kutusunun içindeki konuma ayarlayarak startlength metin kutusunun içinde program aracılığıyla taşıyabilirsiniz. Şapka işaretinin taşınması için metin kutusunun odağı olmalıdır.
Uyarı
Bu yöntem herhangi bir parametre olmadan çağrılırsa, alternatif bir yöntem kullanılır. Bu alternatif yöntem sınıfından devralır Control . Çağrıldığında, giriş odağını denetime ayarlar ve denetimin içeriğini seçer. Daha fazla bilgi için bkz. Control.Select yöntemi.