I have been trying to find out how to bind data to a
System.Windows.Forms.DomainUpDown() control.
Currently I have only come up with:
private void Init() { List<string> list = new List<string>(); list = get4000Strings(); //4000 items foreach (string item in list) { domainUpDown1.Items.Add(item); } } private List<string> get4000Strings() { List<string> l = new List<string>(); for (int i = 0; i < 4000; i++) { l.Add(i.ToString()); } return l; }
The
DomainUpDown.Itemscollection has anAddRange()method that takes anICollection(implemented byList<T>), so you could just doHowever, if you have that much items to show, I would suggest you use a
ComboBoxhavingDropDownStyleset toDropDownList. It will allow you to databind directly to the list (e.g.comboBox1.DataSource = list;), especially if the list changes often, as you won’t have to refill the ComboBox each time, just change the datasource…