Solved

the about dialog.

Posted on 2008-06-24
3
239 Views
Last Modified: 2013-12-16
I added the about dialog to my windows application.

private void btnAbout_Click(object sender, EventArgs e)
        {
            InitialPrices.AboutBox.ShowDialog();
        }
Error      6      An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Form.ShowDialog()'      C:\SvnWork\InitialPriceReporting\DotNet\InitialPriceReporting\Form1.cs      1443      13      InitialPriceReporting

Now the code for About.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;

namespace InitialPrices
{
    partial class AboutBox : Form
    {
        public AboutBox()
        {
            InitializeComponent();

            //  Initialize the AboutBox to display the product information from the assembly information.
            //  Change assembly information settings for your application through either:
            //  - Project->Properties->Application->Assembly Information
            //  - AssemblyInfo.cs
            this.Text = String.Format("About {0}", AssemblyTitle);
            this.labelProductName.Text = AssemblyProduct;
            this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
            this.labelCopyright.Text = AssemblyCopyright;
            this.labelCompanyName.Text = AssemblyCompany;
            this.textBoxDescription.Text = AssemblyDescription;
        }
what should i do?
0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
oxyoo earned 500 total points
ID: 21857173
Try changing:

private void btnAbout_Click(object sender, EventArgs e)
        {
            InitialPrices.AboutBox.ShowDialog();
        }

To:

private void btnAbout_Click(object sender, EventArgs e)
        {
            InitialPrices.AboutBox aboutDialog = new InitialPrices.AboutBox();
          aboutDialog.ShowDialog();
        }

0
 

Author Comment

by:mathieu_cupryk
ID: 21857218
u have to create an instance then call the method showdialog throught that instance?
0
 
LVL 10

Expert Comment

by:oxyoo
ID: 21857586
Yes that is correct, the ShowDialog method is not a static method. Therefor you need to first create an instance of the dialog class and call ShowDialog on that instance.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now