PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
MDI Woes...
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
MDI Woes...
![]() |
MDI Woes... |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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! |
|
|
|
#2 |
|
Guest
Posts: n/a
|
When you mean main form you are speaking of the parent form? correct.
"DarthCoder" wrote: > 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! |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Yes. Thank you. Anyone?
"MasterBlaster" wrote: > When you mean main form you are speaking of the parent form? correct. > > "DarthCoder" wrote: > > > 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! |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

