Combobox

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

Guest

Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks
 
Oh, I forget the mention that the code is the
ComboBox1_SelectedIndexChanged event
 
Try

MsgBox (ComboBox1.Items(ComboBox1.SelectedIndex).ToString)

HTH, Phil
 
Your objects in the combo box are of type "System.Data.DataRowView" whose
"ToString" method returns the object's type name. Also, the text placed
into the combo items will be whatever the object's "ToString" method returns
unless you are using binding. I believe that if you are binding the combo
box to a DataView object, you need to set the ValueMember and DisplayMember
properties of the combo box.


Dennis in Houston
 
Yes I'm binding it to a dataset like this:
cmbCategory.DataSource = Qds.Tables(0)
cmbCategory.DisplayMember = "Category"
where Category is the column that exist in the Qds.Table(0).
but how can I set the ValueMember!!!?
 

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