MDI Woes...

G

Guest

Please bear with me as I am new to the .NET scene as well as to development.
I am writing a smart client mdi application with the 1.1 framework. I wrote
a form handler sub in the the main form that will close the open child form
and load another child based upon the tree or menu item clicked. I am trying
to mirror the look of Windows Explorer, but this is a buisness application
for private placements. Only one child is loaded at a given time and it is
confined to the open area of the parent like the right-hand pane is in
Windows Explorer.

The Issue: The form handler sub works great but it can not be called from
the active child due to the "me." I must use (or so I think...). Here is the
sub:

Public Shared Sub FormHandler(ByVal frmName As String)
' Cursor = Cursors.WaitCursor
' Me.StatusBar1.Panels.Item(6).Text = "Loading Form... Please
wait"
Try
'## first close any open form except default, which serves as
the background
Dim strFrmName As String = frmChild.Name.ToString
'MsgBox(strFrmName)
If Not IsNothing(frmChild) Or Not frmChild.IsDisposed Then
If strFrmName <> "frmDefault" Then
With frmChild
.Opacity = 0
.Hide()
.Close()
End With
'## form is closed, now unlock last deal
Try
Dim sqlparms() As SqlClient.SqlParameter = New
SqlClient.SqlParameter(0) {}
sqlparms(0) = New
SqlClient.SqlParameter("@MMNumber", oProperties.MMNumber)
ExecuteQueryWithNoReturnVal("DelLockedDeals",
oProperties.ConnectionString, sqlparms)
Catch ex As Exception
MessageBox.Show(LogError(oProperties.MMNumber,
"Private Placement", ex.Message.ToString, ex.TargetSite.Name, True), "Private
Placement Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
MessageBox.Show("Previous Deal could not be
unlocked! Please try to unlock it clicking Main > Manage Locked Deals", "Deal
unlock Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Exit Sub
End Try
'## unlock was successful, now lock new deal
DealLock(oProperties.DealID)
End If
End If

'## load the form passed to this sub
Select Case frmName
Case "default"
frmChild = New frmDefault
Case "fND"
frmChild = New frmNewDeal
Case "fD"
frmChild = New frmDeal
Case "fI"
frmChild = New frmIssue
Case "fTD"
frmChild = New frmTakedown
Case "fMA"
frmChild = New frmMaintAnalysts
Case "fMP"
frmChild = New frmMaintPortfolio
Case "fMLF"
frmChild = New frmMaintLawyers
Case "fML"
frmChild = New frmMaintLookup
Case "fAI"
frmChild = New frmAddIssue
Case "fAT"
frmChild = New frmAddTakedown
Case "fRS"
frmChild = New frmReportSelection
Case "fLD"
frmChild = New frmLockedDeals
Case "fSF"
frmChild = New frmSinkingFundAutoFill
Case Else
frmChild = New frmDefault
End Select
'## now set properties and show the form
Me.ActivateMdiChild(frmChild)

With frmChild
.MdiParent = frmChild.Parent
.Dock = DockStyle.Fill
.ControlBox = False
.MinimizeBox = False
.MinimizeBox = False
.Hide()
.WindowState = FormWindowState.Maximized
.Show()
End With
' Cursor = Cursors.Default
' Me.StatusBar1.Panels.Item(6).Text = "Ready"
''FillActiveChildFormToClient()
Catch ex As Exception
' Cursor = Cursors.Default
' StatusBar1.Panels.Item(6).Text = "Error!"
MessageBox.Show(ex.Message.ToString)
End Try

End Sub

My goal is to have a method that can be used by menu, tree, and child form
events to handle the closing and loading of other child forms.

Many thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top