exactly send focus on row and immediately show it to me
Hi everyone
this my code. I can show my search in DataGridVewX1 but i want to move focus on row.
exactly send focus on row and immediately show it to me.
private void btnSearchUser_Click(object sender, EventArgs e)
{
if (txtNameClerk.Text == "" && txtFamilyClerk.Text == "" || (txtMelliCodeClerk.Text == ""))
{
MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
cmd = new SqlCommand("Clerk_Search", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@clrk_Name", txtNameClerk.Text.Trim());
cmd.Parameters.AddWithValue("@clrk_Family", txtFamilyClerk.Text);
cmd.Parameters.AddWithValue("@clrk_MelliCode", txtMelliCodeClerk.Text);
adp = new SqlDataAdapter();
adp.SelectCommand = new SqlCommand();
adp.SelectCommand.Connection = conn;
adp.SelectCommand.CommandText = "Clerk_Search";
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
adp.SelectCommand.Parameters.AddWithValue("@clrk_Name", txtNameClerk.Text);
adp.SelectCommand.Parameters.AddWithValue("@clrk_Family", txtFamilyClerk.Text);
adp.SelectCommand.Parameters.AddWithValue("@clrk_MelliCode", txtMelliCodeClerk.Text);
dtbl = new DataTable();
conn.Open();
idClerk = Convert.ToInt32(cmd.ExecuteScalar());
adp.Fill(dtbl);
conn.Close();
MessageBox.Show(Convert.ToString(idClerk));
foreach (DataGridViewRow d in grd.Rows)
{
if (int.Parse((d.Cells["clrk_Id"].Value.ToString()))==idClerk)
{
int c = d.Index;
grd.Rows[c].Selected = true;
grd.Rows[c].Selected = Focus(); // It ISN'T CORRECT
grd.Focus(); //It ISN'T CORRECT
break;
}
}
}
}//End btnSearchUser*********************************************