devxlogo

Make One Form Parent of Another

Make One Form Parent of Another

Prior to VB5, when you wanted to make a form appear on top of another form, you either made it modal or used an MDIForm with children. If you wanted to go beyond that, you had to use API calls. Starting with VB5, you can use the Show method’s optional ownerform parameter to set one form as the parent of another. This means you always place the child form-not an MDI child-on top of the parent form, even though the parent form remains active. You can also use the style vbModal parameter to force modality, but that defeats any reason to use ownerform. Here’s how you invoke the ownerform parameter, making a form a nonmodal child of a non-MDIForm:

 Private Sub Command1_Click()	Form2.Show , MeEnd Sub
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist