How to implement ComboBox.FindValue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I implement the value equivalent of the ComboBox.FindStringExact
method?

I.e. How do I set the ComboBox.SelectedIndex so that the
ComboBox.SelectedValue object matches one that I specify.

Thanks in advance for any help,
Hal Heinrich
VP Technology
Aralan Solutions Inc.
 
Dennis,

You do not understand the question! It is not how use FindStringExact, which
works with the ComboBox.DisplayMember.

The question is how to find the index corresponding to a specific
ComboBox.ValueMember.

Hal
 
Hal,

When I had not read your answer to Dennis I would have given the same answer
as he.

Therefore it is true that probably Dennis did not understand your question,
probably because of the way the question was asked.

The answer is simple, use a dataview (or defaultview) as datasource and use
a dataview.find to find the rowindex. That you can set to your
selectedindex.

http://msdn.microsoft.com/library/d...ml/frlrfsystemdatadataviewclassfindtopic1.asp

I hope this helps?

Cor
 
Cor,

Thanks for your reply. I'd like to rephrase the question as follows:

Can you provide an implementation for the following function definition?

Public Function FindValue(ByVal cb As System.Windows.Forms.ComboBox,
ByVal obj As Object) As Integer
'Parameters
' cb
' the ComboBox to be searched
' obj
' the Object to search for
'
'Return Value
' The zero-based index of the first item found; returns -1 if no
match is found.
'
'Remarks
' Uses the Equals method of the Object class to determine a match
' returns the index for which the following is true:
' obj.Equals(cb.SelectedItem)
'
End Function

Thanks,
Hal
 

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

Back
Top