Re: specifying selected item in a listbox
From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 02/26/04
- Next message: Herfried K. Wagner [MVP]: "Re: How to use QBColor in VB.NET?"
- Previous message: Herfried K. Wagner [MVP]: "Re: using c code in vb.net projects"
- In reply to: Cor: "Re: specifying selected item in a listbox"
- Messages sorted by: [ date ] [ thread ]
Date: 26 Feb 2004 22:45:36 +0100
Cor,
* "Cor" <non@non.com> scripsit:
>> Dim i As Integer = Me.ListBox1.FindString(Me.TextBox1.Text)
>> If i = ListBox.NoMatches Then
>> Me.ListBox1.SelectedIndex = -1
>> Else
>> Me.ListBox1.SelectedIndex = i
>> End If
>> End Sub
>> ///
>
> This is kicking,
>
> Some (maybe what longer) time ago I got every time a messages from
> Herfried.
>
> "Better is findstringexact"
>
> But very much "better" is
>
> \\\
> me.listbox1.SelectedIndex = Me.ListBox1.FindStringexact(Me.TextBox1.Text)
> ///
>
> I would not have written this if I had not seen that findstringexact
I used 'FindString' because it allows to search for parts of the string.
If there are items...
Cor
Corina
Corinna
Corrina
Corrinna
... typing "Corr" into the textbox will select "Corrina".
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet/>
- Next message: Herfried K. Wagner [MVP]: "Re: How to use QBColor in VB.NET?"
- Previous message: Herfried K. Wagner [MVP]: "Re: using c code in vb.net projects"
- In reply to: Cor: "Re: specifying selected item in a listbox"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|