Forum Discussion

Dewayne_Pinion's avatar
Dewayne_Pinion
Contributor
11 years ago

Wait for form to load

I am trying to figure out how to use a wait method with my program and its objects. I need to wait for a particular form with a datagrid to load before I can continue. The control is being rather inconsistent with load times and is giving me fits. Using the information below, how should I go about scripting a wait to allow the form to load fully before continuing?

 

FullName - Sys.Process("M3.AKShell").WinFormsObject("frmMainVsd").WinFormsObject("tableLayoutPanel1").WinFormsObject("dockPanel").WinFormsObject("DockWindow", "", 2).WinFormsObject("DockPane", "", 1).WinFormsObject("Holder").WinFormsObject("AP").WinFormsObject("tabAP").WinFormsObject("tpVendor").WinFormsObject("tscVendor").WinFormsObject("ToolStripContentPanel", "", 1).WinFormsObject("tlpVendor").WinFormsObject("pnlVendorGrids").WinFormsObject("dgvVendorDetails")

 

MappedName - Aliases.M3_AKShell.frmMainVsd.tableLayoutPanel1.dockPanel.DockWindow.DockPane.Holder.AP.tabAP.tpVendor.tscVendor.ToolStripContentPanel.tlpVendor.pnlVendorGrids.dgvVendorDetails

 

Name - WinFormsObject("dgvVendorDetails")

 

WndClass - WindowsForms10.Window.8.app.0.3917f2_r17_ad1

 

ClrClassName - M3DataGridView

 

ClrFullClassName - M3.CustomControls.M3DataGridView

1 Reply

  • rickh_28's avatar
    rickh_28
    Occasional Contributor

    It looks like your best bet would probably be to use the WaitAliasChild method, and the Exists property, along with a RefreshMappingInfo call. It ends up looking like this:

     

    var w = Aliases.mySoftware.myForm.WaitAliasChild("myControl", 10000);

    if (!w.Exists) mySoftware.RefreshMappingInfo;

     

    So, in the case of your code, it would probably be something like:

     

    var w = Aliases.M3_AKShell.frmMainVsd.tableLayoutPanel1.

    dockPanel.DockWindow.DockPane.Holder.AP.tabAP.

    tpVendor.tscVendor.ToolStripContentPanel.tlpVendor.

    pnlVendorGrids.WaitAliasChild("dgvVendorDetails", 10000)

    /*If statement is optional - if you're having trouble getting name mapping to work, include it, otherwise disregard*/

    if (!w.Exists) mySoftware.RefreshMappingInfo;

     

    Good luck!