public ListValues(MultySelectList owner, IDictionary <string, string> dctSource, IList <string> lstSelected) { InitializeComponent(); _owner = owner; _lstSelected = lstSelected; if (dctSource == null || dctSource.Count == 0) { return; } chbValues.DataSource = new BindingSource(dctSource, null); chbValues.ValueMember = "Key"; chbValues.DisplayMember = "Value"; for (int i = 0; i < chbValues.Items.Count; i++) { KeyValuePair <string, string> item = (KeyValuePair <string, string>)chbValues.Items[i]; if (_lstSelected.Contains(item.Key)) { chbValues.SetItemChecked(i, true); } } chbValues.Focus(); }
public ListValues(MultySelectList owner, IDictionary<string, string> dctSource, IList<string> lstSelected) { InitializeComponent(); _owner = owner; _lstSelected = lstSelected; if (dctSource == null || dctSource.Count == 0) return; chbValues.DataSource = new BindingSource(dctSource, null); chbValues.ValueMember = "Key"; chbValues.DisplayMember = "Value"; for (int i = 0; i < chbValues.Items.Count; i++) { KeyValuePair<string, string> item = (KeyValuePair<string, string>)chbValues.Items[i]; if(_lstSelected.Contains(item.Key)) chbValues.SetItemChecked(i, true); } chbValues.Focus(); }