Hi,
I would like to display a text box showing the currently selected cells in a grid as an Excel like string, e.g. Sheet1!A1:B2.
I can format the string ok, but my problem is that the grid's 'Selected' property only returns a list of individual cells, rows, and columns, but not the ranges!
It seems likely that these will be stored internally as a list of selection ranges (perhaps as a topleft and bottomright pair of points), if so, is there any way to get at the actual ranges? If this is not possible can you suggest the best way to work out the ranges from the selection object? For example, if the cells collection (and rows and columns for that matter) is ordered in any particular way then that would help. :)
Thanks.
Brian
There is no intrinsic support for determining ranges of selected cells. The SelectedCellsCollection class (returned by the UltraGrid.Selected.Cells property) exposes a Sort method, which sorts them by visible order, as going from top to bottom and left to right. Once you have this sorted list, you could compare adjacent values by the visible positions of the associated rows/columns to determine where the "breaks" in the run are.
I hadn't noticed the Sort() method, that should help a lot! :) Thanks!