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