20-07-19, 05:45 PM
ضع هذا الكود :
ضع هذا الكود في حدث textBox2_KeyDown
أو ضعه في حدث textBox2_TextChanged :
PHP كود :
private void SearchAllColumns(string AllColumns)
{
if (AllColumns.Length > 0)
{
string Sqlstr = "Select * From CONTRACTORS where S_N Like '%" + AllColumns + "%' or NAME_OF_CONTRACTOR Like '%" + AllColumns + "%' or CONTRACTOR_WORKS Like'%" + AllColumns + "%' or PORJECT_NAME Like '%" + AllColumns + "%' or PROJECT_NUMBER = '" + AllColumns + "' or TOTAL_OF_WORKS = '" + AllColumns + "'";
SqlDataAdapter Dadpt = new SqlDataAdapter(Sqlstr, sqlcon);
DataTable DTR = new DataTable();
Dadpt.Fill(DTR);
dataGridView1.DataSource = DTR;
}
else if (AllColumns.Length == 0)
{
string Sqlstr = "Select * From CONTRACTORS ";
SqlDataAdapter Dadpt = new SqlDataAdapter(Sqlstr, sqlcon);
DataTable DTR = new DataTable();
Dadpt.Fill(DTR);
dataGridView1.DataSource = DTR;
}
}
ضع هذا الكود في حدث textBox2_KeyDown
PHP كود :
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode==Keys.Enter)
{
SearchAllColumns(textBox2.Text);
}
}
أو ضعه في حدث textBox2_TextChanged :
PHP كود :
private void textBox2_TextChanged(object sender, EventArgs e)
{
SearchAllColumns(textBox2.Text);
}
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
