Working with Dev Express XtraPivotGrid - Trying to obtain column/row headings
By using the following code, I am able to simulate a click on any cell within the pivot grid and obtain both its actual value and display value:
colCount = pgCtrl.Cells.ColumnCount
rowCount = pgCtrl.Cells.RowCount
For rows = 0 to rowCount -1
For cols = 0 to colCount - 1
cellW = pgCtrl.cells.GetCellInfo(cols, rows).bounds.get_Width
cellH = pgCtrl.cells.GetCellInfo(cols, rows).bounds.get_Height
cellL = pgCtrl.cells.GetCellInfo(cols, rows).bounds.get_Left
CellT = pgCtrl.cells.GetCellInfo(cols, rows).bounds.get_Top
cellX = cellL + (cellW / 2)
CellY = cellT + (cellH / 2)
Call pgCtrl.Click(cellX, cellY)
cellValue = pgCtrl.GetCellValue(cols, rows)
cellDisplay = pgCtrl.cells.GetCellInfo(cols, rows).DisplayText
Log.Message("(" & cols & ", " & rows & "): " & cellValue & ", displayed as: " & cellDisplay)
Next 'cols
Next 'rows
The act of clicking on each cell isn't actually necessary in order to obtain its content, I just couldn't find any other way of setting the focused cell!!
What I am trying to do now is to obtain the column and row headings for the focused cell, but am having difficulty in obtaining these. I think the answer lies in using the native method GetFieldValue(<field as object>, <LastLevelIndex as integer>) but have had no success in using this (I don't fully understand how to specify the first parameter.) Has anyone else come across this and have you been able to get this information? Ideally, I am looking for a simple code snippet along the lines of:
colHeading = pgCtrl.GetFieldValue(<whatever needs to go here>, 0)
rowHeading = pgCtrl.GetFieldValue(<whatever needs to go here>, 0)
Any assistance would be much appreciated.
Regards
Stephen.