combobox Display member

  • Thread starter Thread starter Paul Ilacqua
  • Start date Start date
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
 
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
 
Jeff,
Thanks so much... I totally missed that property, I was looking at text,
SelectedItem etc.
Paul
 
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.
 
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.
 
Back
Top