Forum Discussion

steve_reiss's avatar
steve_reiss
New Contributor
12 years ago

FindChild on .NET Dialog

Hi All,



I'm trying to use the FindChild Method to find 1 or more dynamic listview items in a .NET v4 application dialog.  I have tried a number of ways to find the objects that I need with no sucess.



Information : 




Start at this object and FindChild objs :


 


Sys.Process("Hightail").WPFObject("HwndSource: ShareWindow", "Share").WPFObject("ShareWindow", "Share", 1).WPFObject("MainGrid").WPFObject("ShareManagePanel", "", 1).WPFObject("Grid", "", 1).WPFObject("shareManage").WPFObject("Grid", "", 1).WPFObject("usersListView")


 


 


Find 1 or More of these objects :


 


 


Sys.Process("Hightail").WPFObject("HwndSource: ShareWindow", "Share").WPFObject("ShareWindow", "Share", 1).WPFObject("MainGrid").WPFObject("ShareManagePanel", "", 1).WPFObject("Grid", "", 1).WPFObject("shareManage").WPFObject("Grid", "", 1).WPFObject("usersListView").WPFObject("ListViewItem", "", 1)


 


Expecting to find objects : 


 


WPFObject("ListViewItem", "", 1)


WPFObject("ListViewItem", "", 2)






jScript Code : 



    var ListView = Alias.long_long_object_Path.






      var PropArray = new Array ("Name");


      var ValuesArray = new Array ("ListViewItem");


            


      var allShareUsers = ListView.FindChild(PropArray, ValuesArray, 1);


 






Any assistance would be greatly appreciated!



Steve

5 Replies


  • Hi Steve,


     


    FindChild returns the first found object. If you need to obtain all list views, use the FindAll method. Refer to the this article for more information.


     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    ListViewItem is not the Name of the object, it is the Class of the object I believe.  I think the problem with your code is not that it's not going to work, I think it's that you're mapping to the wrong property.  





    Change your JScript code snippet to the following:





    var ListView = Alias.long_long_object_Path.






          var PropArray = new Array ("ClassName");


          var ValuesArray = new Array ("ListViewItem");


                


          var allShareUsers = ListView.FindChild(PropArray, ValuesArray, 1);



    It could be that ClassName is replaced with WndClassName but I think this should work.  Give it a try and let us know.



    The other possibility is that this might not work either if the ListView items are dynamic...  If they are owner-drawn, you might not be able to find them at all using the FindChild method.  

  • Hi Martin,



    Thanks for your reply... I've tried a number of different combinations to get the FindChild / FindAllChildren method to find the correct objects under the ListView object.  



    I've checked with the developer and he states that the ListItems are NOT ower drawn...



    I've attached a screen shot of the ObjectBrowser with the ListView (starting point - blue hightlight) and the 2 targets highlighted.  I hope this will help...



    Again, this is a .NET dialog 



    Steve
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Wild card * for the name property should work for you. Also notice changes to declaration of allShareUsers for proper iteration of array.



    JScript Ex.:

    var ListView = Alias.long_long_object_Path.


    var PropArray = new Array ("Name");


    var ValuesArray = new Array ("*ListViewItem*");

    //return to array


    var allShareUsers = new VBArray(ListView.FindChild(PropArray, ValuesArray, 1)).toArray();

    //do stuff with it

    for (var c = 0;c < allShareUsers.length;c++){

     allShareUsers.Keys("~[F4]");

     }



    //Hope that helps!