hey Geeks,
I have a datagridview in which i have one button column .. i am using it for selecting some values of that row.
what i want is when that button cell gets focus ,i press enter key (instead of clicking it by mouse) data of that row should be selected .help in guys.
here is my code
private void comboProname_TextChanged(object sender, EventArgs e) //combo box of product name
{ cmd = new SqlCommand("select P_batchno,P_min_stk,P_max_stk,P_vat from PRO where P_name='" + comboProname.Text + "'", conn);
conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
if(comboBthNo.Text=="")
{ dataGridView3.Visible = true; //datagrid which has button column
int i = 0;
dataGridView3.Rows.Insert(i);
dataGridView3.Rows[i].Cells[0].Value = dr["P_batchno"].ToString();
tbMinstk.Text = dr["P_min_stk"].ToString();
tbMaxStk.Text = dr["P_max_stk"].ToString();
tbVAT.Text = dr["P_vat"].ToString();
}
}
conn.Close();
}
private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
{ //for batchno I want dis all to be done on Enter key.
string p;
var senderGrid = (DataGridView)sender;
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
{
//TODO - Button Clicked - Execute Code Here
p = (dataGridView3.Rows[e.RowIndex].Cells[0].Value.ToString());
comboBthNo.Text = p;
}
}
looking forward to ur help frens,thanks in advance