New Index and Item Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

The following VB6 Code snippet assigns the employee number
to each employee name loaded into a combo box,
as a new index.

cboEmployee.AddItem rsEmp.Fields("Name") ' this is processed in a Do Until
Loop


'then the new index is assigned

cboEmployee.ItemData(cboEmployee.NewIndex) = rsEmp.Fields("EmployeeNumber")


this NewIndex can be retrieved and used in code to uniquely identify
each employee


How do you do this in C#

Thanks

Christopher
 
Hi Christopher
For a combo box in c# , there is the proberties selectedText and selected
value ( which can be something different form the selected text .
this.comboBox1.SelectedText
this.comboBox1.SelectedValue

what you can do is to keep the name of fhe employee as the itemText ,
while setting the item value to the number you want to assign to that
number. Hope that helps
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC
 
Back
Top