NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TextBoxBase.Select

Selects a range of text in the text box.

[Visual Basic]
Public Sub Select( _
   ByVal start As Integer, _
   ByVal length As Integer _
)
[C#]
public void Select(
   int start,
   int length
);
[C++]
public: void Select(
   int start,
   int length
);
[JScript]
public function Select(
   start : int,
   length : int
);

Parameters

start
The position of the last character before the beginning of the current text selection in the text box.
length
The number of characters to select.

Remarks

You can use this method to select a substring of text such as when performing a search and replace operation.

Example [C#]

The following example uses TextBox, a derived class, to search the contents of the control for the instance of the word "fox". If found the code selects the word in the control using the Select method. This example assumes that a TextBox named Text1 has been created and its Text property contains the sentence "The quick brown fox jumps over the lazy dog".

[C#]

public void SelectMyString()
{
   // Create a string to search for the word "fox".
   String srchString = "fox";
   // Determine the starting location of the word "fox".
   int index = text1.Text.IndexOf(searchString, 0, 0);
   // Determine if the word was found and select it if it is
   if (index != -1)
   {
      // Select the string using the index and the length of the string.
      text1.Select(index, searchString.Length);
   }
}

See Also

TextBoxBase Class | TextBoxBase Members | System.WinForms Namespace | SelectAll | SelectionLength | SelectionStart | SelectedText