Forum Discussion
sbkeenan
13 years agoFrequent Contributor
Hi Satyabrata and Peter
Whilst my sample below isn't specifically for the DevXpress XtraGrid, I did develop it for use with DevXpress PivotGrids, which most likely, will have the same or similar methods/properties.
My code is in VBScript, but essentially involves accepting the grid as an object, together with the on-screen x,y coordinates of the cell as two integers. It then works out the centre position of the cell and uses that as screen coordinates to return some information about the cell.
As far as I can remember, it works for any cell except those that are sub-totals or totals.
Hopefully you can use this to find the same or similar methods/properties for the XtraGrid.
Regards
Stephen.
Whilst my sample below isn't specifically for the DevXpress XtraGrid, I did develop it for use with DevXpress PivotGrids, which most likely, will have the same or similar methods/properties.
My code is in VBScript, but essentially involves accepting the grid as an object, together with the on-screen x,y coordinates of the cell as two integers. It then works out the centre position of the cell and uses that as screen coordinates to return some information about the cell.
As far as I can remember, it works for any cell except those that are sub-totals or totals.
Sub getPGcellInfo(pivotGrid, x, y)
Dim cellW 'Width of cell
Dim cellH 'Height of cell
Dim cellL 'Left position of cell
Dim cellT 'Top position of cell
Dim cellX 'On-screen X coordinate of cell centre
Dim cellY 'On-screen Y coordinate of cell centre
Dim colHeading 'Column heading for specified cell
Dim rowHeading 'Row heading for specified cell
Dim rowIndex 'Index number of current row
Dim cellValue 'Actual (unformatted) cell value
Dim cellDisplay 'Display value of cell
cellW = pivotGrid.cells.GetCellInfo(x, y).bounds.get_Width
cellH = pivotGrid.cells.GetCellInfo(x, y).bounds.get_Height
cellL = pivotGrid.cells.GetCellInfo(x, y).bounds.get_Left
CellT = pivotGrid.cells.GetCellInfo(x, y).bounds.get_Top
cellX = cellL + (cellW / 2)
CellY = cellT + (cellH / 2)
Call pivotGrid.Click(cellX, cellY)
rowIndex = pivotGrid.Cells.GetFocusedCellInfo.RowFieldIndex
colHeading = pivotGrid.Cells.GetFocusedCellInfo.DataField.Caption
rowHeading = pivotGrid.Cells.GetFocusedCellInfo.Data.GetRowValue(rowIndex)
cellValue = pivotGrid.GetCellValue(x, y)
cellDisplay = pivotGrid.cells.GetCellInfo(x, y).DisplayText
Log.Message(colHeading & "/" & rowHeading & ": (" & x & ", " & y & "): " & cellValue & ", displayed as: " & cellDisplay)
End Sub
Hopefully you can use this to find the same or similar methods/properties for the XtraGrid.
Regards
Stephen.