Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Combobox value programmatically

Status
Not open for further replies.

rwttm001

IS-IT--Management
Nov 20, 2002
26
GB
Simple question but driving me a little insane...

How do I set a combobox to a given value in the "ValueMember" field? ie integer value stored in a database, the combobox would display the relevant "DisplayMember" value. I've looked at the findstringexact method but that searches the "DisplayMember" field so is'nt any use.

TIA
 
You've done the hard work here....something like this should do the trick

Code:
Public Overloads Sub zFindItem(ByVal sText As String)

' Find Item in List using Passed String Value
Dim iFoundPos As Integer
iFoundPos = Me.FindStringExact(sText)
If iFoundPos <> -1 Then Me.SelectedIndex = iFoundPos

End Sub


Sweep
...if it works dont mess with it
 
or
Code:
combobox1.selectedvalue = myvalue


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top