public static void FillComboBox(this ComboBox combo, DbAttributes attributes) { combo.SuspendLayout(); combo.BeginUpdate(); combo.DataSource = null; combo.Text = ""; AddAutoSizeDropWidthHandler(combo); combo.DisplayMember = nameof(DbAttribute.DisplayValue); combo.ValueMember = nameof(DbAttribute.Code); combo.BindingContext = new BindingContext(); combo.DataSource = attributes.GetArray(); combo.SelectedIndex = -1; combo.EndUpdate(); combo.ResumeLayout(); }
private static DataGridViewComboBoxColumn DataGridComboColumn(DbAttributes attributes, string headerText, string name) { var newCombo = new DataGridViewComboBoxColumn(); newCombo.Items.Clear(); newCombo.HeaderText = headerText; newCombo.DataPropertyName = name; newCombo.Name = name; newCombo.Width = 200; newCombo.SortMode = DataGridViewColumnSortMode.Automatic; newCombo.DisplayMember = nameof(DbAttribute.DisplayValue); newCombo.ValueMember = nameof(DbAttribute.Code); newCombo.DataSource = attributes.GetArray(); return(newCombo); }