Forum Discussion

satyabrata's avatar
satyabrata
New Contributor
13 years ago

DevExpress.XtraGrid.GridConrol - ClickCell doesnot works.

Hi,



I am working on a smart client application in which I need to click on a cell inside a grid.Though the cells are not identified/highlighted by test complete,but when I tried to record the action , that is, clicking on a specified cell inside the grid, the following code is generated by test complete




   var gridControl;

  gridControl = Aliases["Process"]["Parent"]["gridObject"];

  gridControl["ClickCell"](0, "Name");



0-Row Number.

Name- Column Header

gridObject - The clrFullClassName is DevExpress.XtraGrid.GridConrol.



When the generated code is executed,Test complete fails to click on the cell.



Please help me with clicking the cell .Is there any internal function or method to be called or do I need to do some settings with the Name mapping feature.



Thanks,

Satya






  • Hi,



    I also have the same problem with ClickCell  method for the object DevExpress.XtraGrid.GridControl .

    I'm using DevExpress v12.1 version.



     Message I received is:

    103 0x80020006 (Unknown name) DevExpress_Xpf_Grid_IScrollInfoOwner_ScrollIntoView.



    I'll also be grateful for help.



    Regards, 

    Peter


  • sbkeenan's avatar
    sbkeenan
    Frequent 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.





    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.

  • satyabrata's avatar
    satyabrata
    New Contributor
    Hi ,



    I got the solution..

    var colhandle = Grid["MainView"]["VisibleColumns"]["Items"](columnNumber)

    Grid["MainView"][SetRowCellValue](rowNumber,colhandle,Value)



    Thanks,

    Satyabrata Saha,

    Pune
  • Anonymous's avatar
    Anonymous

    Hi Guys,



    Official support for Developer Express controls v. 2012 was added to TestComplete 9.10. More info...
  • aminsaurabh's avatar
    aminsaurabh
    Occasional Contributor
    you can always calculate the cordinates on the fly by using

    gridobj.MainView.get_ViewInfo.RowsInfo.GetInfoByHandle(rowhandle).Cells.Item(coloumobj).bounds



    then can pass it to the click .



    or in the newer version of testcomplete you just have to enable the option of developer express in the projectproperties>objectmapping>



    cheers