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.
How to get a specific cell of a DataGridView
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Hirendra SisodiyaRank #258 · 9.8K reputationPosted Mar 16, 2010, 5:01 AM EDT
//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
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 16, 2010, 5:12 AM EDT
you can do it on click event of DataGridView:
DealyRank #9,518 · 205 reputationPosted Mar 17, 2010, 12:27 AM EDT
I can only mark one as Answer though.