Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Embedding Forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bruce - 29 Aug 2004 19:39 GMT
I would like to design a number of separate forms in Visual Studio,
and then at runtime embed them into an area of another form (without
borders and title bars of course). The forms will all be placed in the
same area on the main form, and which forms are used is dependent on
navigation choices made by the user.

The container for the forms could be the main form itself, a panel on
the main form, or a tab page on the main form.

Can anyone point me in the direction of how this might be done?

--Bruce
Herfried K. Wagner [MVP] - 29 Aug 2004 19:47 GMT
* Bruce <bvanderw-news5021@mailblocks.com > scripsit:
> I would like to design a number of separate forms in Visual Studio,
> and then at runtime embed them into an area of another form (without
> borders and title bars of course). The forms will all be placed in the
> same area on the main form, and which forms are used is dependent on
> navigation choices made by the user.

Usercontrols ("Project" -> "Add UserControl...").

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

Chris Dunaway - 30 Aug 2004 14:30 GMT
> The container for the forms could be the main form itself, a panel on
> the main form, or a tab page on the main form.

If you set the form's TopLevel property to False and its Parent property to
the container you want to put it in (Panel, form, etc), it should work
fine.  When you show the form, it will appear inside the container.

Signature

Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Roy Soltoff - 01 Sep 2004 20:03 GMT
Here is some code that I use to do exactly that. I have a series of modules
that implement an interface in a class file to be consistent. The modules
show a form which may show other modal dialogs. The external app
instantiates the module, then uses the following interface method to 'open'
it. If you are going to have the 'module' raise events, you have to do this
by using an interface. The DotNet documentation has a 2-pager that covers
the interface part. See "Walkthrough: Creating and implementing Interfaces".
I also provide methods in the interface to handle a resize of the app to be
able to call the module to resize itself. Likewise, a 'close' method is
useful also shown below.

Public Function OpenModule(ByVal oParent As Object, ByRef oChild As Object)
As Boolean Implements ModInterface.IModule.IGUIModule.OpenModule

Try

frmModule.Parent = oParent ' Form parent

frmModule.gobjClassParent = Me ' Form's class parent

frmModule.Show()

mbolClientOpen = True

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical)

End Try

End Function

Public Sub ResizeModule(ByVal X As Integer, ByVal Y As Integer, ByVal Width
As Integer, ByVal Height As Integer) Implements
ModInterface.IModule.IGUIModule.ResizeModule

Try

frmModule.SetBounds(X, Y, Width, Height)

Catch ex As Exception

PostError(MODNAME, "ResizeModule", ex)

End Try

End Sub

Public Sub CloseModule() Implements
ModInterface.IModule.IGUIModule.CloseModule

Try

frmModule.Visible = False

frmModule.Parent = Nothing

Catch ex As Exception

PostError(MODNAME, "CloseModule", ex)

End Try

End Sub

> I would like to design a number of separate forms in Visual Studio,
> and then at runtime embed them into an area of another form (without
[quoted text clipped - 8 lines]
>
> --Bruce

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.