ComboBox

D

David Fúnez

Hi;

I have a combobox that works ok, it displays the name of the customer
[cliente] in the combobox, but i want to display de Id_customer [id_cliente]
value in a textbox, i tryed this but is not what i want:

** This works ok ***
Dim cmd As SqlCeCommand = cn.CreateCommand
cmd.CommandText = "SELECT id_cliente, nombre FROM clientes ORDER BY nombre"
Dim da As New SqlCeDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)

cmbBox.DataSource = ds.Tables(0)
cmbBox.DisplayMember = "Nombre"
cmbBox.ValueMember = "Id_cliente"

** the code to display the id_cliente***
Private Sub cmbBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cmbBox.SelectedIndexChanged
Label4.Text = cmbBox.SelectedIndex.ToString
End Sub

Thanks on advance.
 
D

David Fúnez

Thanks;

Solved with this:

Private Sub cmbBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cmbBox.SelectedIndexChanged

Dim row As DataRowView = CType(cmbBox.Items(cmbBox.SelectedIndex),
DataRowView)

Label4.Text = row("id_cliente")

End Sub
 

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