FryDay_Boy Posted June 12, 2005 Posted June 12, 2005 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 Quote
Machaira Posted June 13, 2005 Posted June 13, 2005 Add more controls to the form and set their datasource properties just as you did the combobox. Quote Here's what I'm up to.
donnacha Posted June 14, 2005 Posted June 14, 2005 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" Quote Hamlet
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.