This project is read-only.

Get first cell from selected row

Aug 20, 2009 at 12:11 PM


I'm currently learning how to use this great grid (thanks to the development team).

I want to get the value from the first cell from the selected row and I'm using a simple code like:

grid1[grid1.Selection.ActivePosition.Row, 1].ToString()

I have filled the grid with some data (for example 10 rows) . In some cases the ActivepositionRow is -1 even that I have selected a row in the grid (for example the 5th row).


Aug 21, 2009 at 7:25 AM



I think that ActivePosition is FocusedRow and not SelectedRow. And you'll have a problem when several Rows are selected.

You should try to use grid.Selection.GetSelectionRegion().GetRowsIndex() to get all selected indexes. And then take the first one, perhaps sorting them if you don't want the first which has been selected but the upper one.