Forum Discussion

ak's avatar
ak
Occasional Contributor
13 years ago

How can I access (click) to the cell of a table derived from XtraTreeList of DevExpress.

Hi,



I can't find a way to click on a check-box inside a table which is also and XtraTreeList without using screen coordinate. (see attached picture)

I look into the availables method which provide by the object (XtraTreeList), there is not methode ClickCell or any method to simulate the click on the cell.



For example, I want to click on the check-box in the 1st column, at the node TT (see picture below). How can i do it. Please help!



I'm able to get the node, the column without problem. I'm also able to set the value of the cell to true, so the check-box will be check. But since, it is not a Click, the even behind the check-box does not fire.



All helps are very appreciated






  • Hi,


     


    You can try using the following approach (refer to the control's documentation to learn more about the Bounds property):


    var wTreeList = // obtain your tree from the Object Browser


    var cell = // obtain the cell to click it


    var bounds = cell.Bounds;


    wTreeList.Click(bounds.Left +  bounds.Width / 2,


                             bounds.Top + bounds.Height / 2);




     


    If this doesn't help, can you create a sample app and post it here so we can try to test it?


     

  • ak's avatar
    ak
    Occasional Contributor
    Hi,



    Here a sample of the tree list. I'm unable to get the cell. I look in the object inspector of TestComplete 9.10, there is no method offer to get the cell.



    Please help.

  • Hi,


     


    Thanks for the sample. I've used the script from this How To article to enable a check box next to the specified tree item. I only modified the Main_Sample function in this way:


    function Main_Sample()


    {   


      var p = Sys.Process("TreeListCheckbox");


      var wMain = p.WinFormsObject("Form1");


      wMain.Activate();


      var wTreeList = wMain.WinFormsObject("treeList1");


      var nodes = wTreeList.Nodes;


      var nodeStr = "root|b";


      var colStr = "Visible";


      


      if (clickNode(wTreeList, nodes, nodeStr, colStr, 0))


      {


        Log.Message("The '" + nodeStr + "' node was successfully clicked.");


      }


    }


     

  • ak's avatar
    ak
    Occasional Contributor
    Hi Tanya,



    Big thank for the help. It works fine. I did not know that I have to get into the ViewInfo to be able to get access to the cell. Thank you again.



    I do have another question related to this. I don't understand why when I create a form which use the private DevExpress.XtraTreeList.TreeList directly. Example

    private DevExpress.XtraTreeList.TreeList aTree;



    I saw a method ClickCell in Object Inpsector. But when I create a class which inherite from a class using XTraTreeList. Then, i don't see the method ClickCell.



    Here an example that the method ClickCell is not available:



    class MyTreeList : DevExpress.XtraTreeList.TreeList

    {

         public MyTreeList()

         {

         }

    }



    partial class Form

    {

        private void InitializeComponent()

        {

             this.treeList = new MyTreeList();

             .

             .

             .

        }

    }




  • Hi,


     


    You need to add the TreeListCheckbox.MyTreeList class to Object Mapping's Developer Express Controls  WinForms | XtraTreeList to show TestComplete that your class is inherited from the known one.


    Actually, after that, you can use the ClickCellXY method to enable/disable the check box.


     

  • ak's avatar
    ak
    Occasional Contributor


    Hi,

    Thank you so much for the clarification.
  • pratyushdash's avatar
    pratyushdash
    Occasional Contributor
    Hi,



    I am in a similar mess with xtratreelist control.

    I am unable to select the item from the list view.



    Am attaching the application.Can anybody please help me with this?