I had found some code I used in VB2005 to show an about box. The about
box itself was just a windows form with a button on it. The button had
no code behind it but it's dialogresult property is set to cancel. The
help about menu item showed the form like this:
Private Sub AboutToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AboutToolStripMenuItem.Click
Try
Dim myAboutDialog As New About
myAboutDialog.ShowDialog()
If myAboutDialog.DialogResult =
System.Windows.Forms.DialogResult.OK Then
myAboutDialog.Dispose()
End If
Catch ex As Exception
System.Console.WriteLine(ex.Message.ToString())
End Try
End Sub
I'm playing with VB2008 now and I was dupliating this application in
2008 and I noticed it has an about box template form to use. I notice
it's ok button had the code me.close behind it.
Can anyone tell me which way I should do this in 2008?
Should I still call the form by saying
Private Sub AboutToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AboutToolStripMenuItem.Click
Try
Dim myAboutDialog As New AboutBox1
myAboutDialog.ShowDialog()
If myAboutDialog.DialogResult =
System.Windows.Forms.DialogResult.OK Then
myAboutDialog.Dispose()
End If
Catch ex As Exception
System.Console.WriteLine(ex.Message.ToString())
End Try
End Sub
What are the differences in how the about form is being handled?
> I had found some code I used in VB2005 to show an about box. The about
> box itself was just a windows form with a button on it. The button had
> no code behind it but it's dialogresult property is set to cancel. The
> help about menu item showed the form like this:
Just how did the About form close if the OK button's Click event
handler had no code?
> Private Sub AboutToolStripMenuItem_Click(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
[quoted text clipped - 14 lines]
> 2008 and I noticed it has an about box template form to use. I notice
> it's ok button had the code me.close behind it.
FYI, VS2005 also had an About form template.
> Can anyone tell me which way I should do this in 2008?
>
[quoted text clipped - 16 lines]
>
> What are the differences in how the about form is being handled?
IMHO, there is no reason to check the dialogresult from an about form.
In the code you have, all it does is dispose of the form object if the
dialog result is OK. Why not just let the garbage collector handle the
object's disposition? All you really need to do is instantiate the
form object and show the form, again, IMHO.
Armin Zingler - 13 May 2008 22:12 GMT
<zacks@construction-imaging.com> schrieb
On May 13, 4:28 pm, cj <c...@nospam.nospam> wrote:
> I had found some code I used in VB2005 to show an about box. The about
> box itself was just a windows form with a button on it. The button had
> no code behind it but it's dialogresult property is set to cancel. The
> help about menu item showed the form like this:
Just how did the About form close if the OK button's Click event
handler had no code?
====
By pushing the button, the Form's dialogresult property is set
automatically because the button's dialogresult property is set. In
addition, as soon as the property is set, the Showdialog function
returns. Therefore it works without writing additional code.
Armin