Forum Discussion

neha_renukdas's avatar
neha_renukdas
Occasional Contributor
13 years ago

How to Find() the object by its property if its changing dynamically

Hi,



Below is the path of the oblect which I need to find. its basically a window pane with a grid in it. There are multiple grids on the screen and only one of them is active and I have to find such a window pane and right click on the gridcell.



Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").WinFormsObject("UnitTest.qbis").WinFormsObject("xTabProject").WinFormsObject("XtraTabPage", "Dimensional View2").WinFormsObject("DimensionalBrowserUC").WinFormsObject("xtraScrollableControl").WinFormsObject("QuestPanel", "", 2).WinFormsObject("DimensionTableNewUC").WinFormsObject("gridControl");



From the above path, this part changes frequently:

WinFormsObject("QuestPanel", "", 1).WinFormsObject("DimensionTableNewUC").WinFormsObject("gridControl"); OR

WinFormsObject("QuestPanel", "", 3).WinFormsObject("DimensionTableNewUC").WinFormsObject("gridControl"); etc....



and to find a active grid, there is only one property of gridControl which is "BackColor.Name" and : (BackColor=(Object),Name= "GradientActive")



I tried every possibility like: used FindChild(), Used Extended find, Used Find function and searched the obj by using PropName as "BackColor.Name".... But it did not work.



Can anyone please tell me how to do it? OR please give the link, material on which this type of  problem is discussed, article for the solution.... :(

8 Replies

  • Try something like below



    set Parent_obj=Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").WinFormsObject("UnitTest.qbis").WinFormsObject("xTabProject").WinFormsObject("XtraTabPage", "Dimensional View2").WinFormsObject("DimensionalBrowserUC").WinFormsObject("xtraScrollableControl")



    set grid_obj=Parent_obj.find(array("BackColor","name"),array("<bg colour>","GradientActive"),2)



    or try find some unique combination.
  • neha_renukdas's avatar
    neha_renukdas
    Occasional Contributor
    Hi Krushna,



    Thanks for replying... I tried your combination but its not working... because "Name" is one unique property and another unique property is its "BackColor"... which is again an object... means BackColor is a property which is itself an object, which has again a property called Name in it.

    Means Object ("gridControl") has two unique properties "Name" and "BackColor.Name" but I dont know how to use this "BackColor.Name" property... It is not recognizing it...

  • Hi,



    How do you call Find with this property exactly? Can you post here code you use?
  • neha_renukdas's avatar
    neha_renukdas
    Occasional Contributor
    Here is the code which i used:

    function DimViewDragFieldToActiveGrid(itemPath)

    {

    Aliases.QBIS.MainMirandaConsole.Activate();

    var PropNames, PropValues,ds;

    PropNames = new Array("BackColor.Name","Name");

    PropValues = new Array("GradientActiveCaption","WinFormsObject(\"DimensionTableNewUC\")");

    var obj = Aliases.QBIS.MainMirandaConsole.MdiClient.Find(PropNames, PropValues, 1000, true);

    var grid = obj.WinFormsObject("gridControl");

     var gridTop = grid.ScreenLeft;

     var gridLeft = grid.ScreenTop;


    PropNames = new Array("Name","VisibleOnScreen");

      PropValues = new Array("WinFormsObject(\"tvFields\")",true);

      ds = Aliases.QBIS.MainMirandaConsole.MdiClient.Find(PropNames, PropValues, 1000, true);

      ds.ClickItem(itemPath,0);

      var node = ds.SelectedNode;

      var nPnt = ds.WindowToScreen(node.Bounds.X,node.Bounds.Y);

      var dropX = gridLeft - (nPnt.X);

      var dropY = gridTop - (nPnt.Y); 

     ds.Drag(node.Bounds.X+5,node.Bounds.Y+5,dropX,dropY); 

    }

  • Hi,



    Your screenshots demonstrate BackColor property of the object which is the parent of 'DimensionTableNewUC'. You're probably trying to find an object using the BackColor.Name and Name property values belonging to different objects in the tree. You should use a property combination which belongs to a single object, not to several ones, in a single Find call.
  • neha_renukdas's avatar
    neha_renukdas
    Occasional Contributor
    Hi Jared,



    Actually, all the objects in the tree, for eg: xTabProject, DimensionalBrowserUC, QuestPanel, gridControl... have BackColor.Name property. At a time, I tried to find only a single object i.e. either DimensionalBrowserUC / gridControl which have BackColor.Name = "GradientActiveCaption"

    I sent you the screenshot of xTabProject just to show you the preperties of parent object.

    But actually I want to search DimensionalBrowserUC whose  BackColor.Name = "GradientActiveCaption" and then I can click on its respective gridControl.

    because if there are multiple QuestPanels dropped then it does not know which gridControl is active and which one to click.

  • Hi,



    What do you see if you expand the BackColol.Name property (click '...' next to it)? Does it help if you try searching by BackColol.Name.OleValue instead of just BackColol.Name?
  • neha_renukdas's avatar
    neha_renukdas
    Occasional Contributor
    Hi Jared,









    Now it is working with both the ways: "BackColor.Name" and "BackColor.Name.OleValue"




    The only thing I needed to change was that, while doing any operation like RClick(), Click(), DblClick().... I have to give the whole path of the object, like




    obj. Winformasobject("DimensionalNewUC").Winformsobject("gridControl").Click();









    Thanks Jared. Will bother you again for a new problem :)