Tuesday, May 11, 2010

What are parent and child forms in visual basic?

I'm a pretty new programmer and have started using vb 2005. Can somebody explain to me the concept of parent and child forms? It'd be much appreciated.What are parent and child forms in visual basic?
Usually child forms are forms that are opened by code in another form (the parent form). Many times the parent form will manage a set of records while a child form will allow you to edit one specific record (master/details) and prevent data from being added to the parent form while a child record is being edited. Sometimes child forms just give general information, ask questions, or display errors. If you have ever done a MessageBox.ShowDialog then that form is a child form of whichever form called it.What are parent and child forms in visual basic?
Yes a parent form is basically the main base window and can spawn child forms like an Open/save form or your own custom forms. Child forms can also either be modal or modeless. A modal form just assumes control over the application and doesn't let you work with any other forms until you close it or hide it. A modeless form is pretty much like a tool window that you can access at any time and won't interfere with the execution of the rest of the program much. I don't know if that's what they're called in VB but the concept its still the same.
If you are talking about MDI applications. Think of how excel has a parent form for the application, and child forms for each workbook.
A child form is created by the parent if I'm not mistaken.

No comments:

Post a Comment