Solved

the about dialog.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

18 Experts available now in Live!

Get 1:1 Help Now