?
Solved

Form within a Form

Posted on 2002-04-29
10
Medium Priority
?
140 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 53

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 200 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

777 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