• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Form within a Form

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
buffalonian4
Asked:
buffalonian4
1 Solution
 
RAJzCommented:
use the second form as vbmodal

for e.g
form2.show vbModal

0
 
raizonCommented:
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
 
rspahitzCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Ryan ChongCommented:
Maybe use the SetParent API will do.
0
 
buffalonian4Author Commented:
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
 
rspahitzCommented:
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
 
buffalonian4Author Commented:
Rspahitz, thanks, I'll give it a go.  
0
 
buffalonian4Author Commented:
This appears to work, although, I think will need to rethink my design functionality.  Thanks.
0
 
rspahitzCommented:
Thanks for the "A".  Just curious, which of the three choices did you pick or are you leaning toward?
0
 
buffalonian4Author Commented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now