469,281 Members | 2,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

Get the value of one cell from a DataGridView?

Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that was
doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin
Feb 21 '07 #1
3 77769
Edwin Smith <sm**********@aol.comschrieb:
private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that was
doubleclicked]

}
e.RowIndex contains the index of the row you double-clicked.
This should give you a start...

Markus
Feb 21 '07 #2

"Edwin Smith" <sm**********@aol.comschreef in bericht
news:e4**************@TK2MSFTNGP04.phx.gbl...
Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that
was doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin



textbox1.Text =
pATIENTSDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

Regards,
Anne
Feb 21 '07 #3

"AvdP" <apuntvdpuntploegatplanetpuntnlwrote in message
news:45**********************@text.nova.planet.nl. ..
>
"Edwin Smith" <sm**********@aol.comschreef in bericht
news:e4**************@TK2MSFTNGP04.phx.gbl...
>Hello:

I have a DataGridView control and I want to doubleclick a row and get a
single cell value.

Here's a snippet:

private void pATIENTSDataGridView_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)

{

textbox1.Text = [the contents of the cell at column4 of the row that
was doubleclicked]

}

This should be a simple task but I can't seem to get it.

Thanks

Edwin


textbox1.Text =
pATIENTSDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString();

Regards,
Anne
Works great! Thanks.

I had already figured out the e.RowIndex and e.ColumnIndex values. I just
couldn't figure out how to use them to get the cell I wanted.

Edwin
Feb 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Morten Snedker | last post: by
2 posts views Thread by paolol | last post: by
1 post views Thread by =?Utf-8?B?QnJpYW5ESA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.