How do I get the About box to appear in C#?
Asked Answered
N

6

13

I have an About box in my C# project using Microsoft's Visual C# 2008 Express Edition named AboutBox1. I have made it look how I want it in the design view, but how do I make it appear when the About link in the Help menu is clicked?

This codes makes an About box appear, but it looks blank. It's not the one I designed.

  private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
  {
     AboutBox1 box = new AboutBox1();
     box.ShowDialog();
  }

Any thoughts or suggestions would be appreciated. Thanks.

Newmann answered 29/12, 2009 at 23:3 Comment(1)
Perhaps my code sample is misleading. Originally, I was thinking that I could do something like AboutBox1.ShowDialog(); but ShowDialog() does not seem to be a member of AboutBox1.Newmann
M
17

Got it.

The about box is driven off of assembly properties for your project.

Go to Project -> 'ProjectName' Properties -> Assembly Information.

You set all of the information there.

If you try to set the information in the Property Explorer it will simply be over written at run time by what ever is in this window.

Cheers, Mike

Meir answered 29/12, 2009 at 23:19 Comment(0)
R
10

It sounds to me like a borked designer surface... have you hit save and rebuilt it? Perhaps close the IDE, reopen it, and check that your carefully designed form is still pretty?

BTW, when using ShowDialog you should also use using (since it doesn't Dispose() itself when shown with ShowDialog):

using(AboutBox1 box = new AboutBox1()) {
    box.ShowDialog(this);
}
Relativize answered 29/12, 2009 at 23:8 Comment(0)
H
3

Did you remove the method-call to 'InitializeComponent' in the constructor of your AboutBox - form ?

Your constructor should at least look like this:

    public partial class AboutBox : Form
    {
        public AboutBox()
        {
            InitializeComponent ();
        }
    }

Where the InitializeComponent method call should be the first line in the constructor.

Heelpiece answered 29/12, 2009 at 23:8 Comment(2)
if you remove the InitializeComponent() from the constructor you will recieve a run time exception.Meir
No, you won't get a runtime exception. Have you tried it ? Create a new winforms-project, add a button on the form, and remove the InitializeComponent line from the constructor ...Heelpiece
A
0

If it appears but is blank, the problem is in AboutBox1. Show us some of that code.

Aciniform answered 29/12, 2009 at 23:9 Comment(0)
N
0

I faced same problem before but I solved it by removing the statements below the InitializeComponent();

Default code:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
        this.Text = String.Format("About {0} {0}", AssemblyTitle);
        this.labelProductName.Text = AssemblyProduct;
        this.labelVersion.Text = String.Format("Version {0} {0}", AssemblyVersion);
        this.labelCopyright.Text = AssemblyCopyright;
        this.labelCompanyName.Text = AssemblyCompany;
        this.textBoxDescription.Text = AssemblyDescription;
    }
}

My final code:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
    }
}
Narva answered 19/2, 2011 at 8:44 Comment(1)
I'd keep in at least the version line. Since else you need to update the version in two places every time it changes. And you're bound to forget one.Beg
D
0

I couldn't find the project / project name/ assembly properties.

But commenting out the lines after InitializeComponent(); worked for me.

This is how mine looks:

 public frmAboutBox1()
    {
        InitializeComponent();
        //this.Text = String.Format("About {0}", AssemblyTitle);
        //this.labelMyFFEProductName.Text = AssemblyProduct;
        //this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
        //this.labelCopyright.Text = AssemblyCopyright;
        //this.labelCompanyName.Text = AssemblyCompany;
        //this.textBoxDescription.Text = AssemblyDescription;
    }

If you are an amateur like me, to find these lines, click the AboutBox in the project explorer, and hit the View Code button <>.

Discoid answered 16/3, 2013 at 4:41 Comment(1)
Is this an answer, I hope you should comment it than posting as an answer.Giacinta

© 2022 - 2025 — McMap. All rights reserved.