How do you get the selected cell of a gridview?
I would like to know how to get the selected cell of a gridview, like for example if a gridview has 4 rows of 4 buttons each, how do you tell if you are clicking button 1 row 1 or button 3 row 4?
Please dont direct me to MSDN or other such sites, I cant understand them and dont find them useful at all.
Re: How do you get the selected cell of a gridview?
You do something like: -
DataGridView dv;
dv.CurrentCell = new DataGridViewCell(row_index, col_index);
Re: How do you get the selected cell of a gridview?
Thanks but that doesnt look like it would get the cell your clicking on, it looks more like it would set it.
Re: How do you get the selected cell of a gridview?
Personally i prefer to use the Repeater, as it includes a few extra options by default and also can be easily formatted to show data anyway you please.. It does take a little extra to setup, but personally i find it worth the work..
The Gridview by default only returns the current row but not the current column.. there are methods to hack a similar sort of functionality into the Gridview, but that would require links to MSDN and such, also none seem to really return the specific column you clicked on, but rely on scanning through the cells for markers or changes...
Now what specifically are you trying to achieve, then perhaps i can spot you some code and pointers to complete this..