Datagridview, get the text from the first cell of the selected row
Hi all, after some searching around the msdn im no closer to an answer so time to ask you guys for some help.
I have a data grid view and i want to show the text from the first column of the selected row (regardless of what cell in that row is selected) in a text box.
So for example in this picture:
http://img87.imageshack.us/img87/2127/snap1th.jpg
The 1st column of the selected rows text is 'California' so that should be sent to the textbox.
Any helps much appreciated, Thanks.
Re: Datagridview, get the text from the first cell of the selected row
There's a difference between "selected" and "current" in a DataGridView. "Selected" means highlighted and you can, depending on the circumstances, have multiple cells or rows selected at the same time. "Current" means containing the caret, and only one cell and row can contain the caret at a time. The grid's CurrentRow property will return a DataGridViewRow, obviously containing the current row. As with all rows, that has a Cells collection, which you can index by column name or ordinal.