开发者

Cannot Show a New Form (aboutBox) in C#

开发者 https://www.devze.com 2023-04-11 12:15 出处:网络
IDE/Language: Visual Studio 2010 Professional C# I am banging my head against the wall on this one. I have my application nearly finished but I am running into a silly problem. I cannot launch my abo

IDE/Language: Visual Studio 2010 Professional C#

I am banging my head against the wall on this one. I have my application nearly finished but I am running into a silly problem. I cannot launch my about box when my About Box menu item is clicked. It either shows nothing or creates a new form.

I have tried several suggestions found on Stack Overflow below however none of them launch my aboutBox class. (Note: I tried these separately and not all at once):

Snippet from mainWindow.cs:

 private void aboutMyProjectToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Run(new aboutBox()); //throws and exception

        (new aboutBox()).ShowDialog(); //creates a new form does not run the one I created

        aboutBox about = new aboutBox(); 
        about.ShowDialog(); //creates a new form does not run the one I created
    }

This is what is in aboutBox.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using开发者_如何学JAVA System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace myNamespace
{
    public partial class aboutBox : Form
    {
        public void aboutBoxMain()
        {
            InitializeComponent();
            this.Text = String.Format("About {0}", AssemblyTitle);
            this.labelProductName.Text = AssemblyProduct;
            this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
            this.labelCopyright.Text = AssemblyCopyright;
            this.textBoxDescription.Text = AssemblyDescription;
        }
    #region "Assembly Accessors"
    ...
    #endregion
    #region "On-click Events"
    ...
    #endregion
    }
}

Thank you in advanced!


    public void aboutBoxMain()
    {
        InitializeComponent();
        // etc..
    }

You destroyed the constructor somehow, possibly after renaming the form and trying to get rid of the compiler error. Fix:

    public aboutBox() 
    {
        InitializeComponent();
        // etc..
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消