code_junkie

C# Update combobox bound to generic list

Nov 13th, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. private List<string> mAllianceList = new List<string>();
  2.  
  3. private void FillAllianceList()
  4. {
  5. // Add alliance name to member alliance list
  6. foreach (Village alliance in alliances)
  7. {
  8. mAllianceList.Add(alliance.AllianceName);
  9. }
  10.  
  11. // Bind alliance combobox to alliance list
  12. this.cboAlliances.DataSource = mAllianceList;
  13. }
  14.  
  15. private List<string> mAllianceList = new List<string>();
  16. private BindingList<string> bindingList;
  17.  
  18. private void FillAllianceList()
  19. {
  20. // Add alliance name to member alliance list
  21. foreach (Village alliance in alliances)
  22. {
  23. mAllianceList.Add(alliance.AllianceName);
  24. }
  25.  
  26. bindingList = new BindingList<string>(mAllianceList);
  27.  
  28. // Bind alliance combobox to alliance list
  29. this.cboAlliances.DataSource = bindingList;
  30. }
  31.  
  32. mAllianceList.Sort();
  33. bindingList = new BindingList<string>(mAllianceList);
  34. this.cboAlliances.DataSource = bindingList;
  35.  
  36. private List<Project> ProjectList;
  37. this.ProductNameComboBox.DataSource = ProjectList;
  38.  
  39. this.ProductNameComboBox.DisplayMember = "AppName";
  40. this.ProductNameComboBox.ValueMember = "ID";
Add Comment
Please, Sign In to add comment