StrataFrame Forum

BrowseDialog Search freezing issue

http://forum.strataframe.net/Topic15591.aspx

By Ross L. Rooker, Sr. - 4/14/2008

I added a custom browse dialog frmCustomersMaintenanceBrowseDialog and it works perfectly if I have the CustomerMaintenance form appear first, then have the user click on the BROWSE button on the Maintenance Toolbar. BUt I want the Browse Dialog to appear first so I added the following to the frmCustomersMaintenance_Load event:

private void frmCustomersMaintenance_Load(object sender, EventArgs e)

{

this.frmCustomersMaintenanceBrowseDialog.ShowDialog();

}

This does bring up the Browse Dialog first, but when the user clicks SEARCH, the screen freezes. I am not doing any out of the ordinary with the BO.

Is there something else I need to do. What might be helpful is if you code tell me how I could bring up a messagebox showing me the SELECT statement just before it is executed? Or the Connection Striing? I already read the other parts of the forum on screen freeze but they do not seem to help with the issue.

Thanks.

By Trent L. Taylor - 4/14/2008

The problem is that the form has not fully loaded at this point.  When you do something like this you are always better off overrides the On method versus handling the event since you cannot control the event order.  But if you override the On method you can then control at what point your logic will be fired.  In this case, I would probably put this in the OnCreateControl method instead of the Load

Overrides Protected Sub OnCreateControl(...)
    MyBase.OnCreateControl(...)

    MyBrowse.ShowDialog()
End SUb

By Ross L. Rooker, Sr. - 4/14/2008

Here is what I used:

protected override void OnCreateControl()

{

this.OnCreateControl();

frmCustomersMaintenanceBrowseDialog.ShowDialog();

}

When it runs I get a "stack overflow" on the "this.OnCreateControl()"

By Trent L. Taylor - 4/14/2008

There is something else trying to manage the window handle which is causing a nesting issue since the MDI owner hasn't been fully updated yet.  This is common when using an MDIClient.  Just override the OnShown method and place your code there.  At this point the forum will be fully instantiated and belong to the MDI container...thus removing the stack overflow.
By Ross L. Rooker, Sr. - 4/14/2008

This worked. Wish that the actual form would not be visible before the Search Dialog appeared. This may be something you want to change in the framework in the future to have a setting that would allow the browse dialog to appear first as an option.
By Trent L. Taylor - 4/14/2008

This may be something you want to change in the framework in the future to have a setting that would allow the browse dialog to appear first as an option.

Not a framework issue...it's a .NET issue.  This is because of the MDI form logic.  If you want to get around this then you can create your own MDI environment. 

By Trent L. Taylor - 4/14/2008

You could also overwrite the OnParentChanged method and the form will not have been shown yet....and you wouldn't have to write your own MDI environment Smile

Overrides Protected Sub OnParentChanged(...)
    MyBrowseDialog.ShowDialog()
End SUb
By Ross L. Rooker, Sr. - 4/14/2008

That works 100 percent better, but when you close the CustomerMaintenance form with the red X in the top right corner, the browse dialog appears and you need to CANCEL it on the CANCEL button. If you know what needs to be twaeked to have the form close without the browse coming up, then this solution work be PERFECT for everyone wanting to do this.
By Trent L. Taylor - 4/14/2008

That behavior I couldn't reproduce....it worked fine when I ran it.