combobox FindString

A

apple

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?
 
M

mklapp

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top