Hi All,
I see that this topic was discussed back on august 23rd, but I didn't see a
real answer. I have a VB.NET MDI app. A particular menu action on the MDI
parent is to call an OpenFileDialog box. If the result is ok, I show a form
with related information about the file.
However, there are only specific files allowed. In the MDI child form load
event, I check the validity of the file (right version, not open in another
app, etc.). Based on a post I saw from Jay (repeated in the thread here on
august 23rd), I throw an exception if there's a problem with the file.
Here's some code. first, how I call the form (in the MDI Parent):
Protected Sub MDICDLNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Menu_CDL_New.Click
Dim result As DialogResult = CDL2X_CDL_Pick.ShowDialog()
If result = DialogResult.OK Then
MainMDI.ActiveForm.Refresh()
CDL.CDLfile = CDL2X_CDL_Pick.FileName
winnum = winnum + 1
Try
Dim NewCDLwin As New Analyze
NewCDLwin.Text = NewCDLwin.Text + " " + winnum.ToString
NewCDLwin.MdiParent = Me
NewCDLwin.Show()
Catch ex As Exception
winnum = winnum - 1
MessageBox.Show(ex.Message, "Open CDL Failure",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
In the child form, I check a bunch of stuff about the file, and if it isn't
the right type of file, or the wrong version, or if it's open in another
app, I throw an exception in various locations throughout the form load
code:
Throw New Exception(CDL2X_CDL_Name.Text + " is not a supported CDL
Version!")
However, the form still loads! What am I missing? Based on Jay's post on
PCReview and again here, throwing an exception should cancel the load event,
but it doesn't.
any thoughts?
TIA
Lee