Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all,

 

I have use the following code to populate a combo box, but I would like to display more than the "empoyee id" (e.g. company, mobile phone number etc etc...) when Button2 is clicked. Can some one please enlighten me ??? Thank you very much !

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim connstring As String

Dim cconnection As OleDbConnection

Dim DistrictAdapter As OleDbDataAdapter

Dim ds_name As New Data.DataSet

 

connstring = ..........

cconnection = New OleDbConnection(connstring)

cconnection.Open()

 

DistrictAdapter = New OleDbDataAdapter("Select * from [resource master list] where [First Name] = '" & TextBox1.Text & "'", cconnection)

DistrictAdapter.Fill(ds_name, "nametable")

 

ComboBox1.DataSource = ds_name.Tables("nametable")

ComboBox1.ValueMember = "Employee ID"

ComboBox1.DisplayMember = "LAST NAME"

 

cconnection.Close()

cconnection = Nothing

 

End Sub

------------------------------------------------------------------------

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

TextBox2.Text = ComboBox1.SelectedValue

End Sub

End Class

Posted

If you wish to display more than one item in the combobox then try adding a phantom column to rour data set

e.g.

my_dataset.Tables(0).Columns.Add("Full_Name", System.Type.GetType("System.String"), _

"Title_Name + ' ' + First_Name + ' ' + Middle_Name + ' ' + Surname")

 

This creates a column "Full_Name" that is made up of the other columns. You could then use ComboBox1.DisplayMember = "Full_Name"

Hamlet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...