Solved

the about dialog.

Posted on 2008-06-24
3
241 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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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