Category / Section
How to manage Row Index in GridGroupingControl?
1 min read
The GridGroupingControl is not a row index-based grid. The ideal way to tackle this is to rely on the displayed elements. This sample script replaces the GreatGrandChildName26 to MyName.
SwfWindow("GridGroupingControl").Move 347,344
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").SetCurrentCell 5,"parentID"
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").ExpandRecord 5
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").SetCurrentCell 10,"childID"
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").ExpandRecord 10
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").SetCurrentCell 15,"grandChildID"
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").ExpandRecord 15
tablename = SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").GetTableNameByLevel(3)
colIndex = 2
colname = SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").GetColumnName(tablename, colIndex)
SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").SetCellData 19, colname, "MyName"
This sample can be referred in Essential QTP\28.2.3\WinForms\Samples\bin\4.6.2\Grid\GGC_Hierarchical.exe
The helper function GetRowElement can also be used to know the
kind of the element behind the row.
For row = 1 To SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").GetRowCount() -1 Step 1
MsgBox SwfWindow("GridGroupingControl").SwfObject("gridGroupingControl1").GetRowElement(row)
Next