Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
select datagridviewButtonCell on Pressing Enter key,Winforms
varsha dodiya
Jul 21 2014 3:27 AM
1.6k
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to convert .mp4 file to .avi format
How to capture frame of a .mp4 file while uploading