Nerdy_Girl88
asked on
Mulitple combobox columns
Desperately trying to figure this out?? I have ask this question before but atill having problems with it.
HOW DO I MAKE A COMBOBOX WITH MULITIPLE COLUMNS?
I have an access database, usinf visual studio.net. I have a form with a combobox and lots of text fields, the combobox is used to search for a particular record. I need the combobox to hold the firstname lastname and ID columns of the datatable.
I am looking at creating datatable that will have one column with the ID and another with the last name and the firstname as a concatenated string. I don't know how i go concatenating two datatable cloumns into one.
Desperately needing help here.
Nerdy Girl
HOW DO I MAKE A COMBOBOX WITH MULITIPLE COLUMNS?
I have an access database, usinf visual studio.net. I have a form with a combobox and lots of text fields, the combobox is used to search for a particular record. I need the combobox to hold the firstname lastname and ID columns of the datatable.
I am looking at creating datatable that will have one column with the ID and another with the last name and the firstname as a concatenated string. I don't know how i go concatenating two datatable cloumns into one.
Desperately needing help here.
Nerdy Girl
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use a class to store your value
-------------------------- ------
Class details
Private _id, _firstName, _lastName As String
Public Sub New(ByVal id As String, ByVal lastname As String, ByVal firstname As String)
Me._firstName = firstname
Me._id = id
Me._lastName = lastname
End Sub
Public Property ID() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal Value As String)
_firstName = Value
End Set
End Property
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal Value As String)
_lastName = Value
End Set
End Property
Public Overrides Function toString() As String
Return ID 'the property you want to display in combo box
End Function
End Class
-------------------------- --------
use this code to add your object to combo box
Dim temp As New details("89", "gggg", "jsgdghg")
Me.ComboBox1.Items.Add(tem p)
---------------------
The to string method is important your define the string you wnat to display in the combobox
Regards
Prakash
--------------------------
Class details
Private _id, _firstName, _lastName As String
Public Sub New(ByVal id As String, ByVal lastname As String, ByVal firstname As String)
Me._firstName = firstname
Me._id = id
Me._lastName = lastname
End Sub
Public Property ID() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal Value As String)
_firstName = Value
End Set
End Property
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal Value As String)
_lastName = Value
End Set
End Property
Public Overrides Function toString() As String
Return ID 'the property you want to display in combo box
End Function
End Class
--------------------------
use this code to add your object to combo box
Dim temp As New details("89", "gggg", "jsgdghg")
Me.ComboBox1.Items.Add(tem
---------------------
The to string method is important your define the string you wnat to display in the combobox
Regards
Prakash
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your help....
Flavo
will your code create a datatable with a column called sName. 'Which will be of string type holding the First name and last name.
RonaldBiemans
That is exactly what i want to do.
Just to confirm
dt.Columns.Add("Names", GetType(System.String), "Fname + ' ' + Lname")
Fname and Lname are already columns in the dt table right?
And this will add a new column to that dt called Names.
Thanks
Flavo
will your code create a datatable with a column called sName. 'Which will be of string type holding the First name and last name.
RonaldBiemans
That is exactly what i want to do.
Just to confirm
dt.Columns.Add("Names", GetType(System.String), "Fname + ' ' + Lname")
Fname and Lname are already columns in the dt table right?
And this will add a new column to that dt called Names.
Thanks
ASKER
RonaldBiemans
All the controls are bound to the same dataset, I have a search combobox that uses the same datatable in the dataset, If I use a different dataset to fill the combobox how will my dataset know which record to display to the form.
Does theis make sense.
All the controls are bound to the same dataset, I have a search combobox that uses the same datatable in the dataset, If I use a different dataset to fill the combobox how will my dataset know which record to display to the form.
Does theis make sense.
ASKER
Thnaks guys that works, however now my master detail form doesn't work. It will only work for the master part.
I think it was because of the way i hace designed by master detail form.
Thanks you have help me with this problem I will post an new thread for the master detail problem.
Cheers
I think it was because of the way i hace designed by master detail form.
Thanks you have help me with this problem I will post an new thread for the master detail problem.
Cheers
http://www.codeproject.com/vb/net/multicolumncombo.asp
ComboBox/Icon_ComboBox/art
combobox/multicolumncombo.