Hello,
I have a dataGridView with 3 columns and a button in each
row. When user clicks on the button a row x i want to get the value of
cell (row=x,column=1) and save it in a string.
Any suggestions?
Thank you in advance.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hirendra SisodiyaPosted Mar 16, 2010, 9:01 AM
//Assume that column index of button cell is 3 thenyou can use this code :
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string str = "";
if (e.RowIndex != -1)
{
if (e.ColumnIndex == 3)
{
str = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}
}
}
thanks
DealyPosted Mar 17, 2010, 4:27 AM
I can only mark one as Answer though.
Amit ChoudharyPosted Mar 16, 2010, 9:12 AM
you can do it on click event of DataGridView: