This documentation is archived and is not being maintained.

ComboBox.FindString Method

Finds the first item in the ComboBox that starts with the specified string.

Overload List

Finds the first item in the combo box that starts with the specified string.

[Visual Basic] Overloads Public Function FindString(String) As Integer
[C#] public int FindString(string);
[C++] public: int FindString(String*);
[JScript] public function FindString(String) : int;

Finds the first item after the given index which starts with the given string. The search is not case sensitive.

[Visual Basic] Overloads Public Function FindString(String, Integer) As Integer
[C#] public int FindString(string, int);
[C++] public: int FindString(String*, int);
[JScript] public function FindString(String, int) : int;


[Visual Basic, C#, C++] The following example illustrates the usage of the FindString method and SelectedIndex property. The example is part of a runnable code sample in the ComboBox class overview.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of FindString. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub findButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim index As Integer
    index = comboBox1.FindString(textBox2.Text)
    comboBox1.SelectedIndex = index
End Sub

private void findButton_Click(object sender, System.EventArgs e) {
    int index = comboBox1.FindString(textBox2.Text);
    comboBox1.SelectedIndex = index;

    void findButton_Click(Object* /*sender*/, System::EventArgs* /*e*/) {
        int index = comboBox1->FindString(textBox2->Text);
        comboBox1->SelectedIndex = index;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

ComboBox Class | ComboBox Members | System.Windows.Forms Namespace