combobox Display member

P

Paul Ilacqua

Data Entry App Using VB 2005

I'm filling a combobox (code below) with a List(Of CWO) , a class I
defined.. No problem. Lookups return a CWO type, again no problem.

I have a "Load Last Record" function that will populate the form along with
that combobox with values from the database. The value coming in is the
"ValueMember", not the "DisplayMember". How can I load the "ValueMember" but
have the combobox display the DisplayMember?


Dim CWOList As New List(Of CWO)

Dim MyCWO As CWO
SqlDr = ESData.GetReader(sSQL, False)

Do While SqlDr.Read
MyCWO = New CWO
MyCWO.CWONumber = SqlDr(0).ToString
MyCWO.CWOText = SqlDr(1).ToString
CWOList.Add(MyCWO)
Loop
SqlDr.Close()
With ComboBox1
.DataSource = CWOList
.ValueMember = "CWONumber"
.DisplayMember = "CWONumAndText"
End With

set a combobox value that has been filled with list of
 
J

Jeff Johnson

Data Entry App Using VB 2005

I'm filling a combobox (code below) with a List(Of CWO) , a class I
defined.. No problem. Lookups return a CWO type, again no problem.

I have a "Load Last Record" function that will populate the form along
with that combobox with values from the database. The value coming in is
the "ValueMember", not the "DisplayMember". How can I load the
"ValueMember" but have the combobox display the DisplayMember?

ComboBox1.SelectedValue = yourValueMemberVariable
 
P

Paul Ilacqua

Jeff,
Thanks so much... I totally missed that property, I was looking at text,
SelectedItem etc.
Paul
 
P

Paul Ilacqua

One other issue... after I load the last record, and post it, I clear the
screen, after the combobox's text propert is set to "", I can no longer
populate the load last record.
 
J

Jeff Johnson

One other issue... after I load the last record, and post it, I clear the
screen, after the combobox's text propert is set to "", I can no longer
populate the load last record.

I have no idea what you're trying to say. "Populate the load last record"
makes no sense to me.

And to clear a combo box, you shouldn't set its text to "" but rather set
its SelectedIndex to -1.
 

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