Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2008

Tip: Looking for answers? Try searching our database.

aboutbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cj - 13 May 2008 21:28 GMT
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?
zacks@construction-imaging.com - 13 May 2008 21:44 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.