split container

  • Thread starter Thread starter Mihai
  • Start date Start date
M

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
 
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
 
Thanks Izzy !
I will try. !

Mihai
Izzy said:
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
 
Izzy said:
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
 
Back
Top