, , # , , . . , , combobox, , combobox. combobox KeyUp.
( , , ), DataTable, dt_source, combobox, : id (int) ().
DataTable dt_source = new DataTable("table");
dt_source.Columns.Add("id", typeof(int));
dt_source.Columns.Add("name", typeof(string));
And here is my KeyUp method as follows:
private void cmb_box_KeyUp(object sender, KeyEventArgs e)
{
string srch = cmb_box.Text;
string srch_str = "ABackCDeleteEFGHIJKLMNOPQRSpaceTUVWXYZD1D2D3D4D5D6D7D8D9D0";
if (srch_str.IndexOf(e.KeyCode.ToString()) >= 0)
{
cmb_box.DisplayMember = "name";
cmb_box.ValueMember = "id";
DataView dv_source = new DataView(dt_source);
dv_source.RowFilter = "name LIKE '%"+ srch +"%'";
cmb_box.DataSource = dv_source;
cmb_box.SelectedIndex = -1;
cmb_box.Text = srch;
cmb_box.Select(100,0);
cmb_box.DroppedDown = true;
}
}
source
share