Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error creating window handle while databinding in a MDIChild form load

Status
Not open for further replies.

tsites

Programmer
Oct 23, 2002
8
US
Background: I am using VS.Net 2003 version 7.1.3088 .Net Framework 1.1 Version 1.1.4322 and am using Visual Basic Windows Forms.

I have an MDI form that is the start up project. It is a form that has menu control with 5 main menu containing 10 sub menu items each. In the MDI Form's constructor, I call a procedure to load a global business object which supplies information from my SQL Server 2000 database. In the form load of the MDI form, I load an MDI child form using the syntax:

Private frm as frmMDIChild

Private Sub Form_Load....
frm = new frmMDIChild
frm.MDIParent = Me
frm.Show

End Sub

When I run it, it gets to the line frm.Show and gives me the error:

An unhandled exception of type 'System.OutOfMemoryException' occurred
in system.windows.forms.dll

Additional information: Error creating window handle.

I put a breakpoint in the form load of the mdi child form. It is a form with a tab control with three tabs. These tabs contain around 50-75 controls including labels, text boxes, check boxes, command buttons, and one true db grid. There is also a true db grid below and some more command buttons.

The textboxes and checkboxes in the tab control are bound to the business object created in the load of the mdi form. It does the first 5-10 text boxes just fine. Then it gives the error:

An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.

If I comment out that line, it just does it on the next one. If I comment out all the rest of the databinding, the form comes up fine. I have checked my memory and I shouldn't be having any memory issues. I have worked with the program trying to not load some objects until I need them, but nothing seems to help. If anyone can give me assistance, I would appreciate it.

Thanks in advance.
 
It ended up being my own fault. I had it binded to properties that had a problem in the set part of the properties.
 
What exactly did you do to fix the problem? I have a similar situation where I am loading a user control and a form and getting the same error.
 
I had this happen to me twice today, and both times it was something in the event order. I had a combobox selectedindexchanged event handler, which was set before the control was bound. When the control was bound, the index changes, but since it wasn't bound, what I was doing with it in the event handler created exceptions because it accessed data objects that haven't been created yet because it wasn't bound yet ... and the circle continues.

Second time it happened was much the same. The only thing that really confuses me is why it generated the above exception and didn't drop me off at the relevant code. It just stopped me at the .Show method for the form, but I could set breakpoints in _Load and see it fail trying to set the cbo's valuemember (which triggered the event, which it doesn't step into). Couldn't VS maybe put me at step or two closer to the problem? IE, which objects where generated the exception?

________________________________________
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top