如何让“关于”框出现在 C# 中?

发布于 2024-08-16 17:47:52 字数 365 浏览 3 评论 0原文

我的 C# 项目中有一个名为 AboutBox1 的“关于”框,使用 Microsoft 的 Visual C# 2008 Express Edition。我已经让它在设计视图中看起来像我想要的那样,但是当单击“帮助”菜单中的“关于”链接时如何使其显示?

此代码使“关于”框出现,但它看起来是空白的。这不是我设计的。

  private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
  {
     AboutBox1 box = new AboutBox1();
     box.ShowDialog();
  }

任何想法或建议将不胜感激。谢谢。

I have an About box in my C# project using Microsoft's Visual C# 2008 Express Edition named AboutBox1. I have made it look how I want it in the design view, but how do I make it appear when the About link in the Help menu is clicked?

This codes makes an About box appear, but it looks blank. It's not the one I designed.

  private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
  {
     AboutBox1 box = new AboutBox1();
     box.ShowDialog();
  }

Any thoughts or suggestions would be appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

顾北清歌寒 2024-08-23 17:47:53

知道了。

关于框已从项目的程序集属性中删除。

转到项目 -> “项目名称”属性 ->装配信息。

您在那里设置所有信息。

如果您尝试在属性资源管理器中设置信息,它将在运行时被该窗口中的内容覆盖。

干杯,
麦克风

Got it.

The about box is driven off of assembly properties for your project.

Go to Project -> 'ProjectName' Properties -> Assembly Information.

You set all of the information there.

If you try to set the information in the Property Explorer it will simply be over written at run time by what ever is in this window.

Cheers,
Mike

青丝拂面 2024-08-23 17:47:53

在我看来,这就像一个无聊的设计师界面……你点击保存并重建它了吗?也许关闭 IDE,重新打开它,然后检查您精心设计的表单是否仍然漂亮?

顺便说一句,当使用 ShowDialog 时,您还应该使用 using (因为当使用 ShowDialog 显示时,它本身不会 Dispose() )代码>):

using(AboutBox1 box = new AboutBox1()) {
    box.ShowDialog(this);
}

It sounds to me like a borked designer surface... have you hit save and rebuilt it? Perhaps close the IDE, reopen it, and check that your carefully designed form is still pretty?

BTW, when using ShowDialog you should also use using (since it doesn't Dispose() itself when shown with ShowDialog):

using(AboutBox1 box = new AboutBox1()) {
    box.ShowDialog(this);
}
我恋#小黄人 2024-08-23 17:47:53

您是否在 AboutBox - 表单的构造函数中删除了对“InitializeComponent”的方法调用?

您的构造函数至少应该如下所示:

    public partial class AboutBox : Form
    {
        public AboutBox()
        {
            InitializeComponent ();
        }
    }

其中 InitializeComponent 方法调用应该是构造函数中的第一行。

Did you remove the method-call to 'InitializeComponent' in the constructor of your AboutBox - form ?

Your constructor should at least look like this:

    public partial class AboutBox : Form
    {
        public AboutBox()
        {
            InitializeComponent ();
        }
    }

Where the InitializeComponent method call should be the first line in the constructor.

帅哥哥的热头脑 2024-08-23 17:47:53

如果出现但为空,则问题出在 AboutBox1 中。向我们展示一些代码。

If it appears but is blank, the problem is in AboutBox1. Show us some of that code.

未央 2024-08-23 17:47:53

我之前遇到过同样的问题,但我通过删除 InitializeComponent(); 下面的语句解决了它

默认代码:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
        this.Text = String.Format("About {0} {0}", AssemblyTitle);
        this.labelProductName.Text = AssemblyProduct;
        this.labelVersion.Text = String.Format("Version {0} {0}", AssemblyVersion);
        this.labelCopyright.Text = AssemblyCopyright;
        this.labelCompanyName.Text = AssemblyCompany;
        this.textBoxDescription.Text = AssemblyDescription;
    }
}

我的最终代码:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
    }
}

I faced same problem before but I solved it by removing the statements below the InitializeComponent();

Default code:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
        this.Text = String.Format("About {0} {0}", AssemblyTitle);
        this.labelProductName.Text = AssemblyProduct;
        this.labelVersion.Text = String.Format("Version {0} {0}", AssemblyVersion);
        this.labelCopyright.Text = AssemblyCopyright;
        this.labelCompanyName.Text = AssemblyCompany;
        this.textBoxDescription.Text = AssemblyDescription;
    }
}

My final code:

partial class AboutBox1 : Form
{
    public AboutBox1()
    {
        InitializeComponent();
    }
}
猫九 2024-08-23 17:47:53

我找不到项目/项目名称/程序集属性。

但是注释掉 InitializeComponent(); 之后的行对我有用。

这就是我的外观:

 public frmAboutBox1()
    {
        InitializeComponent();
        //this.Text = String.Format("About {0}", AssemblyTitle);
        //this.labelMyFFEProductName.Text = AssemblyProduct;
        //this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
        //this.labelCopyright.Text = AssemblyCopyright;
        //this.labelCompanyName.Text = AssemblyCompany;
        //this.textBoxDescription.Text = AssemblyDescription;
    }

如果您是像我一样的业余爱好者,要找到这些行,请单击项目资源管理器中的 AboutBox,然后点击 View Code 按钮 <>

I couldn't find the project / project name/ assembly properties.

But commenting out the lines after InitializeComponent(); worked for me.

This is how mine looks:

 public frmAboutBox1()
    {
        InitializeComponent();
        //this.Text = String.Format("About {0}", AssemblyTitle);
        //this.labelMyFFEProductName.Text = AssemblyProduct;
        //this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
        //this.labelCopyright.Text = AssemblyCopyright;
        //this.labelCompanyName.Text = AssemblyCompany;
        //this.textBoxDescription.Text = AssemblyDescription;
    }

If you are an amateur like me, to find these lines, click the AboutBox in the project explorer, and hit the View Code button <>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文