I am new to VB programming and need some help with hiding and showing custom dialog boxes. I have designed a dialog box which when opened uses the "shown" event to preload values into comboboxes and solicites user input. The basic code is below. When the dialog is closed, I want to be able to reopen it without changing the users data or reloading the comboboxes
The first time through it works fine. The next time through I cannot get the dialog to show without redefining the instance. The code below appears as though it should work but it will not display the dialog.
Any help would be greatly appreciated.
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Primary.Show()
Catch ex As NullReferenceException
dim Primary as New ResinClass
Primary.ShowDialog()
Finally
If Primary.DialogResult = Windows.Forms.DialogResult.OK Then
Primary.Hide()
Else
Primary.Dispose()
End If
End Try
End Sub
The first time through it works fine. The next time through I cannot get the dialog to show without redefining the instance. The code below appears as though it should work but it will not display the dialog.
Any help would be greatly appreciated.
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Primary.Show()
Catch ex As NullReferenceException
dim Primary as New ResinClass
Primary.ShowDialog()
Finally
If Primary.DialogResult = Windows.Forms.DialogResult.OK Then
Primary.Hide()
Else
Primary.Dispose()
End If
End Try
End Sub