-
listbox
hi , i have a table containing the employee code and the employee name, i need a listbox showing at run time only the employee name and when selected the employee code shld b retreived! is there a way i can fill the list box with the employee code without beeing visible...
thank you
-
First of all use a dataset to connect to the database.
Second, set the listbox datasource and display member to appropriate values,
Third add this code to your event:
Where dsEmployeeInformation is your datasets name
lstUsername is your listbox name
And assuming you have a column named "Employee Code"in your datatable.
Code:
With dsEmployeeInformation.Employee_Information
MessageBox.Show(Convert.ToString(.Rows(lstUsername.SelectedIndex)("Employee Code")))
End With