• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

the about dialog.

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
mathieu_cupryk
Asked:
mathieu_cupryk
  • 2
1 Solution
 
oxyooCommented:
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
 
mathieu_cuprykAuthor Commented:
u have to create an instance then call the method showdialog throught that instance?
0
 
oxyooCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now