Hi Everyone!
I'm using a WinGrid and the AfterCellActivate event to give the user some information about the cell they've clicked. I need a way to get the ActiveCell's position (row and column number). Basically I'm mocking up an application that doesn't need to be written perfeclty now, it just needs to show basic functionality. I haven't written the classes or support for it, just a wingrid and I'm planning on storing some information about a cell in an XML file (click cell, get row and column number, pull that data from the XML) just to show management the look/feel/behavior of the application. (I'll worry about doing it the "right" way after they approve it!
Thanks much in advance!
For a row:
e.Cell.Row.Index
or
e.Cell.Row.VisibleIndex (when you use a filter)
For a column:
You have e.Cell.Column.Index but you should use e.Cell.Colum.Header.VisiblePosition
VisibleIndex on the row is the most reliable way to get the row index, since this will account for filtering and sorting.
For the column, I would use:
this.ultraGrid1.ActiveColScrollRegion.VisibleHeaders.IndexOf(e.Cell.Column.Header);
Note that this method is reliable, but neither of them is terribly efficient. For the row indices, you probably don't have any choice, but it might be a good idea to loop through the VisibleHeaders once and create a Dictionary that stores the columns in order rather than calling IndexOf multiple times.