Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. class Customer
  2. {
  3. public int Id {get; set;}
  4. public int Name {get; set;}
  5. }
  6.  
  7. combobox.DisplayMember = "Name";
  8. combobox.ValueMember = "Id";
  9.  
  10. public Class Customer {
  11. public int CustomerId { get; set; }
  12. public string First { get; set; }
  13. public string Last { get; set; }
  14.  
  15. // here is where you decide what to display in the combo box:
  16. public override string ToString() { return First + Last; }
  17. }
  18.  
  19. // declare customers
  20. Customer []myCustomers = null;
  21.  
  22. // load customers ... then show:
  23. myCombobox.Items.AddRange(myCustomers);
  24.  
  25. var customerObject = (Customer)myCombobox.Items[myCombobox.SelectedIndex];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement