I want my Windows Form Dropdownbox to be read only and not allow any type.
Solution:
Add in the “KeyDown” event the below functionality:
private void cboStudientType_KeyDown(object sender, KeyEventArgs e) { char ch = (char)e.KeyValue; if (!char.IsControl(ch)) { string newTxt = this.cboStudientType.Text + ch; bool found = false; foreach (System.Data.DataRowView item in this.cboStudientType.Items) { string itemString = item.ToString(); if (itemString.StartsWith(newTxt, StringComparison.CurrentCultureIgnoreCase)) { found = true; break; } } if (!found) e.SuppressKeyPress = true; } }