combobox FindString  
Author Message
fix!!!!!!





PostPosted: Tue Jan 06 15:21:07 CST 2004 Top

Winforms >> combobox FindString

Hello, help me please with combobox FindString,
I want to perform a search for an second substring entry in the combobox
items collection. I use the FindString with specifying a starting index
within the ComboBox. I have tried the following but none seem to work:
cmbBox.FindString(strWhat, cmbBox.FindString(strWhat)) - :( don't work
For example:
if Items count is 1 - I have only one item in the items collection,
cmbBox.FindString(strWhat) return 0 - this only one item starts with strWhat
With FindString(strWhat, 0) i receive ArgumentOutOfRangeException error...
Why, if error condition is: "The startIndex is greater than the last index
in the collection."????

How I can do this?

DotNet399  
 
 
mklapp





PostPosted: Tue Jan 06 15:21:07 CST 2004 Top

Winforms >> combobox FindString Hello,

The index specified in the method is the index of the
item just before the one to be searched. To detect the
first occurence, use -1.
Using 0 in a one item list, starts the search with
the "oneth" (second) item not the "zeroth" (first) item.

Your code might work thusly:

cbo.FindString(strWhat, cbo.FindStr(strWhat, -1) )

but it will still fail if the returned index = > the
count of Items - 1

mklapp

>-----Original Message-----
>Hello, help me please with combobox FindString,
>I want to perform a search for an second substring entry
in the combobox
>items collection. I use the FindString with specifying a
starting index
>within the ComboBox. I have tried the following but none
seem to work:
>cmbBox.FindString(strWhat, cmbBox.FindString(strWhat)) -
:( don't work
>For example:
>if Items count is 1 - I have only one item in the items
collection,
>cmbBox.FindString(strWhat) return 0 - this only one item
starts with strWhat
>With FindString(strWhat, 0) i receive
ArgumentOutOfRangeException error...
>Why, if error condition is: "The startIndex is greater
than the last index
>in the collection."????
>
>How I can do this?
>
>
>.
>