I have three forms: A, B and C.
Upon a button being clicked, A displays B. Similarly, B displays C. Both using the ShowDialog() method.
However when I use the Hide() method (inside a Button Click event) on form C to close it, form B also closes.
Why would this be? As far as I can see, it shouldn't be doing this. I certainly didn't write any code to tell it to do that.
Here is the code:
' from Form "A" (MainForm)
Private Sub OrdersDataGridView_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles OrdersDataGridView.CellDoubleClick
ShowViewOrderForm(sender)
End Sub
Private Sub ShowViewOrderForm(ByVal CurrentDGV As DataGridView)
If Not CurrentDGV Is Nothing Then
Dim f As New ViewOrderForm
f.SetOrderNo(CurrentDGV.CurrentRow().Cells().Item(0).Value)
f.SetDeliveryServiceType(CurrentDGV.CurrentRow().Cells().Item(5).Value)
f.ShowDialog()
End If
End Sub
' from Form "B" (ViewOrderForm)
Private Sub IssueOrderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IssueOrderButton.Click
Dim f As New IssueForm
f.SetOrderNo(ThisOrderNo)
f.ShowDialog()
End Sub
' from Form "C" (IssueForm)
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
Me.Hide()
End Sub
UPDATE: I am an idiot. DialogResult
was set to Cancel
on the button as I'd copy+pasted it from the existing Close button and not realised that property was set. Thanks for your suggestions anyway everyone!