private void dataGridViewX1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 27) { dataGridViewX1.Visible = false; PDtxt3.Focus(); } if (e.KeyValue == 13) { dataGridViewX1.Visible = false; PDtxt3.Focus(); } }
private void mtxt1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 27) { this.Close(); } if (e.KeyValue == 13) { con.connection(); DataTable dt = con.show_data("select codemar'کد مرکز',name'نام مرکز' from markaz where code = N'" + mtxt1.Text + "' "); con.Disconnect(); if (dt.Rows.Count == 0) { txt2.Text = ""; mtxt1.Text = ""; } else { mtxt1.Text = dt.Rows[0].ItemArray.GetValue(0).ToString(); txt2.Text = dt.Rows[0].ItemArray.GetValue(1).ToString(); } PDtxt3.Focus(); } if (e.KeyCode == Keys.Down) { dataGridViewX1.Visible = true; dataGridViewX1.Focus(); con.connection(); if (mtxt1.Text == "") { sql = "select codemar'کد مرکز',name'نام مرکز' from markaz"; } else { sql = "select codemar'کد مرکز',name'نام مرکز' from markaz where (codemar LIKE N'" + mtxt1.Text + "'%)"; } dataGridViewX1.DataSource = con.show_data(sql); con.Disconnect(); } }