gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
Hi there
I am attempting to find a way to get an existing form to close and re-open (with the controls re-set).
If I use a method like
..and the user selects 'Yes' then another instance of the form does open as required, but directly over the original.
Is there a method to ensure that the first instance is fully closed before raising the next instance?
Thanks....
This is how the form loads
Labels, ComboBox and TextBoxes added to the Panel
ToolStrip and buttons added to the form
I am attempting to find a way to get an existing form to close and re-open (with the controls re-set).
If I use a method like
VB.NET:
If AppBox.Show("Transaction successfully saved! Process another?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
AccountingMainWindow.Close()
AccountingMainWindow.Refresh()
LoadPettyCashPayment()
Else
AccountingMainWindow.Close()
End If
..and the user selects 'Yes' then another instance of the form does open as required, but directly over the original.
Is there a method to ensure that the first instance is fully closed before raising the next instance?
Thanks....
This is how the form loads
VB.NET:
Public Sub LoadPettyCashPayment()
'Validate petty cash account
Dim vNLDT As DataTable = ReturnDT(NL_Codes, "NL_Codes")
Dim FR() As DataRow = vNLDT.Select("NL_Code = 1220", Nothing)
Dim vPCName As String = NullString(FR(0)("NL_Description"))
If vPCName = "" Then
AppBox.Show("The Petty Cash account (1220) has been deleted, or is invalid!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
'Determine if the Petty cash account has funds in it!
Dim BankDT As DataTable = ReturnDT(A_Bank_Transactions, "A_Bank_Transactions")
Dim vCredit As Double = NullValues(BankDT.Compute("SUM(Credit)", "Nominal_Code = 1220"))
Dim vDebit As Double = NullValues(BankDT.Compute("SUM(Debit)", "Nominal_Code = 1220"))
Dim vBalance As Double = vCredit - vDebit
If vBalance <= 0 Then
AppBox.Show("The current Petty Cash balance is $" & Format(vBalance, "###,##0.00") & ". You will need to add funds (Bank / Transfer) to continue!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
'OK to launch Petty Cash form
'AppBox.Show(vBalance.ToString, MessageBoxButtons.OK, MessageBoxIcon.Information)
AccountingMainWindow = New Form
AccountingMainWindow.Controls.Clear()
AccountingMainWindow.Size = New Point(650, 450)
AccountingMainWindow.Text = "Petty Cash Payment"
Dim vPanel As New Panel
vPanel.Dock = DockStyle.Fill
vPanel.AutoScroll = True
Labels, ComboBox and TextBoxes added to the Panel
ToolStrip and buttons added to the form
VB.NET:
AMGStatusStrip = New StatusStrip
AMGStatusLabel = New ToolStripStatusLabel
AMGProgressBar = New ToolStripProgressBar
AMGStatusStrip.Items.Add(AMGProgressBar)
AMGStatusStrip.Items.Add(AMGStatusLabel)
AccountingMainWindow.Controls.Add(vPanel)
AccountingMainWindow.Controls.Add(vToolStrip)
AccountingMainWindow.Controls.Add(AMGStatusStrip)
AccountingMainWindow.StartPosition = FormStartPosition.CenterParent
AccountingMainWindow.ShowDialog()
Last edited: