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!
Thank you guys, it worked like a charm!
I have until the end of today to finish the mock up of this application. Right now, all I am doing is creating an application that looks like it works in order to give management a look and feel for what we would like to do. So I'm cutting corners, hard coding a lot of stuff just to get the behavior of the app and look and feel going. Once management approves, then I basically start from scratch and do things the right way!
Thanks again!!
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.
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