combo box, 2 columns [*Resolved *]
Hello,
I have a database table with 2 fields, DepartmentCode, and DepartmentName. I want to add the values of these 2 fields into a combo box from the database. I can add one field, but how can you add 2 fields to the combox so that when the user clicks it, it will display all the departmentCode and Department name in 2 columns.
I can do this with just one field, but l am having trouble tying to display the extra field. Is this possible in a combox box?
Thanks in advance,
Steve
Re: combo box, 2 columns [*Resolved *]
Any insight on how you solved it? Someone else reading this thread may be interested as well.
Re: combo box, 2 columns [*Resolved *]
Hello,
Here is the full solution to the problem. Thanks for you help.
VB Code:
//Load the combo box of the department names
cmd.CommandText = "SELECT DepartmentCode + ' ' + DepartmentName AS CodeAndName FROM Department";
OleDbDataReader dReaderDepartments = cmd.ExecuteReader();
while ( dReaderDepartments.Read() )//While there are departments to add to the combo box
{ //Add each item from the data reader to the combo box
cboDepartment.Items.Add( dReaderDepartments.GetString(0) );
cboEmployeeDepartments.Items.Add ( dReaderDepartments.GetString(0) );
}
dReaderDepartments.Close();
cmd.Dispose();