Home All Groups Group Topic Archive Search About
Author
25 Sep 2006 2:29 PM
Mihai
Hi !
If I put on a form a split container , in the left side a main menu and here
is the question how I can put in the right side - in Panel2- a form that is
executed when i choose an option from the menu.?
Is any example somewhere? I serched in MSDN but i cannot find something like
that. I saw outlook 2003 has a behavior like this..

Regards,
Mihai

Author
25 Sep 2006 2:42 PM
Izzy
Mihai,

I have a report menu which does exactly this. Depending of which report
is selected in a grid I load a different form as a subform or midi
child.

Like this:

**************************************************************

Public Sub LoadForm(ByVal Name As String, ByRef Parent As Form)

        Try
            If Not SubForm Is Nothing Then
                SubForm.Close()
                SubForm = Nothing
                GC.Collect()
            End If

            Dim objNewForm As Object =
Activator.CreateInstance(Type.GetType(Name))
            SubForm = DirectCast(objNewForm, Form)
            SubForm.StartPosition = FormStartPosition.Manual
            SubForm.MdiParent = Parent
            SubForm.Location = New Point(0, 163)
            SubForm.Show()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.OKOnly)
        End Try

    End Sub

***************************************************************

If anyone has a better method for doing this, I would be interested in
seeing it.

Hope this helps,
Izzy

Mihai wrote:
Show quoteHide quote
> Hi !
> If I put on a form a split container , in the left side a main menu and here
> is the question how I can put in the right side - in Panel2- a form that is
> executed when i choose an option from the menu.?
> Is any example somewhere? I serched in MSDN but i cannot find something like
> that. I saw outlook 2003 has a behavior like this..
>
> Regards,
> Mihai
Author
25 Sep 2006 2:52 PM
Mihai
Thanks Izzy !
I will try. !

Mihai
Show quoteHide quote
"Izzy" <israel.rich***@gmail.com> wrote in message
news:1159195362.681576.75310@m73g2000cwd.googlegroups.com...
> Mihai,
>
> I have a report menu which does exactly this. Depending of which report
> is selected in a grid I load a different form as a subform or midi
> child.
>
> Like this:
>
> **************************************************************
>
> Public Sub LoadForm(ByVal Name As String, ByRef Parent As Form)
>
>         Try
>             If Not SubForm Is Nothing Then
>                 SubForm.Close()
>                 SubForm = Nothing
>                 GC.Collect()
>             End If
>
>             Dim objNewForm As Object =
> Activator.CreateInstance(Type.GetType(Name))
>             SubForm = DirectCast(objNewForm, Form)
>             SubForm.StartPosition = FormStartPosition.Manual
>             SubForm.MdiParent = Parent
>             SubForm.Location = New Point(0, 163)
>             SubForm.Show()
>         Catch ex As Exception
>             MsgBox(ex.Message, MsgBoxStyle.OKOnly)
>         End Try
>
>     End Sub
>
> ***************************************************************
>
> If anyone has a better method for doing this, I would be interested in
> seeing it.
>
> Hope this helps,
> Izzy
>
> Mihai wrote:
> > Hi !
> > If I put on a form a split container , in the left side a main menu and
here
> > is the question how I can put in the right side - in Panel2- a form that
is
> > executed when i choose an option from the menu.?
> > Is any example somewhere? I serched in MSDN but i cannot find something
like
> > that. I saw outlook 2003 has a behavior like this..
> >
> > Regards,
> > Mihai
>
Author
25 Sep 2006 9:08 PM
Chris Dunaway
Izzy wrote:
>
> Like this:
>
> **************************************************************
>
> Public Sub LoadForm(ByVal Name As String, ByRef Parent As Form)
>
>         Try
>             If Not SubForm Is Nothing Then
>                 SubForm.Close()
>                 SubForm = Nothing
>                 GC.Collect()
>             End If

There is almost *never* any reason to call GC.Collect.  Calling the
form's Close method will result in the form getting disposed.

Another way to show a form inside a panel is to just set the form's
TopLevel property to false and set it's parent to the panel (this code
is from my head, watch for typos):

Dim frm As New SubForm()
frm.TopLevel = False
frm.parent = SplitContainer1.Panel2;
frm.Dock = Dock.Fill
frm.Show()

Instead of using a Form, you might consider also using a UserControl.

Chris