Beeves
This will reduce number of lines
Method 1:
int pos = listBox1.FindString(s,0); //if you have partial string
//select item
if(pos >=0)
listBox1.SelectedIndex = pos;
Method 2:
listBox1.FindStringExact(s,0);// if you have whole string.
if(pos >=0)
listBox1.SelectedIndex = pos;
Shak.
"Beeeeeeeeeeeeves" <Be**************@discussions.microsoft.com> wrote in
message news:DC**********************************@microsof t.com...
Hi
What is the most compact way of selecting an item in a listbox based on
the first part of its string, does it have an inbuilt method?
For instance if I have the items
Aardvark
Antelope
Beaver
Camel
and I 'pass' the string "Ant", then I want 'Antelope' selected. But if I
pass 'Adf' or 'Gup', then nothing should be selected.
Any neat way of accomplishing this?
Thanks