Solved

Form within a Form

Posted on 2002-04-29
10
137 Views
Last Modified: 2010-05-02
I am beginner in VB, and created a main form with a simple command button.  What I would like to know is there a way to pull up a secondary form within a display window on the main form as opposed to using MDI parent/child relationship?
0
Comment
Question by:buffalonian4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Expert Comment

by:RAJz
ID: 6978223
use the second form as vbmodal

for e.g
form2.show vbModal

0
 
LVL 5

Expert Comment

by:raizon
ID: 6978226
Create your second form.

then in the click event for the command button call the show method of the form.

Private Sub Command1_Click()
  form1.show
  form1.startupposition = 1 'Center Owner Screen
End Sub

0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6978948
Based on your title, it sounds like you want  aform embedded within another form.

Although you can't do this without MDI, you can add a picturebox or frame to act as a container for more controls, which can then be moved independently of the main form.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 52

Expert Comment

by:Ryan Chong
ID: 6979483
Maybe use the SetParent API will do.
0
 

Author Comment

by:buffalonian4
ID: 6980950
I guess a little clarification is in order.  What I am trying to do is create a display window similar to a picture or text box on the main form.  When the cmd_click event occurs, I would like to have the second form be pulled up within the "container".  It appears the picturebox or frame idea seems like the right approach, however, I am not sure how to pull up the call the second form within the frame.  Any ideas.
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 50 total points
ID: 6981011
If I understand you correctly, you want to create a sort of portal window where everything from form2 appears inside the view area (picturebox or whatever.)

This is not directly achievable through VB, but there are a few alternatives that I can think of:

1) Do away with form 2 entirely: simply transfer (copy/paste) its entire contents into the picturebox or frame.  (The problem is that you will not get scrollbars which you'll probably want, but this can be worked out if you like the idea.)

2) Show the form, as RAJz indicated, but on load have it move to the desired location.  (This will still allow the user to move it, but at least it starts in the right place.)

3) At run-time, transfer the contents of form 2 into the picturebox/frame.  i.e. take every control and make a copy inside the pic/frame and move it to the correct location relative to the pic/frame.

Pick one or one I haven't thought of and we'll help you get there.
0
 

Author Comment

by:buffalonian4
ID: 6981200
Rspahitz, thanks, I'll give it a go.  
0
 

Author Comment

by:buffalonian4
ID: 6982732
This appears to work, although, I think will need to rethink my design functionality.  Thanks.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6983720
Thanks for the "A".  Just curious, which of the three choices did you pick or are you leaning toward?
0
 

Author Comment

by:buffalonian4
ID: 6983789
Using the PictureBox was what I went with, however, because of my programming limitation and what I am trying to accomplish, I am rethinking the design.  But, as a beginner its the only way to learn through trial and error sometimes.  I appreciate your assistance.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question