private void cbCountry_Leave(object sender, EventArgs e) { DynamicCombo comboBox = sender as DynamicCombo; //cbCountry_SelectionChangeCommitted(comboBox, null); comboBox.Close(); }
public void newRefresh <T>(DynamicCombo comboBox, IEnumerable <T> list) { var tempList = list.Select(item => item).ToList(); if (tempList.Count > 0) { string tempString = comboBox.Text; comboBox.DataSource = tempList; comboBox.SelectedIndex = -1; comboBox.Text = tempString; int listLength; if (comboBox.Items.Count > 10) { listLength = 10; } else { listLength = comboBox.Items.Count; } comboBox.Height = comboBox.ItemHeight * listLength + comboBox.ItemHeight * 2; Cursor.Current = DefaultCursor; } else { comboBox.DataSource = tempList; comboBox.Close(); } comboBox.SelectionStart = comboBox.Text.Length + 1; }