find strings in listbox
#6

According to MSDN:

2

 

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

 

FindString has 2 overloads:

2

Have you looked at this:

2

 

Finds the first item in the 2 that starts with the specified string. The search starts at a specific starting index.

List<int> foundIndexes = new List<int>();
int index = -1, firstIndex = -1;
while ((index = listBox1.FindString("test", index)) !=-1){
if(index == firstIndex ){
break;
}
if (firstIndex == -1){
firstIndex = index;
}
foundIndexes.Add(index);
}

FindString only looks for string that starts with your string, if you want to search for strings that are exactly like your string use FindStringExact:

2

2



Messages In This Thread
[No subject] - by soryjero - 08-01-2013, 01:04 PM
[No subject] - by ReturnKratos - 08-01-2013, 01:19 PM
[No subject] - by soryjero - 08-01-2013, 02:23 PM
[No subject] - by ReturnKratos - 08-01-2013, 03:26 PM
[No subject] - by Wizatek - 08-01-2013, 04:06 PM
[No subject] - by someone - 08-01-2013, 04:46 PM
[No subject] - by soryjero - 08-01-2013, 11:22 PM
[No subject] - by soryjero - 08-02-2013, 08:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)