在 C# 表单应用程序中创建关于对话框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19675910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 15:36:00  来源:igfitidea点击:

creating about dialog box in C# form application

c#forms

提问by Nikunj Aggarwal

I have a C# form application, in that I have a menu where one of the item is help. It has a sub-item About. As you seen in many applications when you click on help a separate dialog box opens up which displays the information.

我有一个 C# 表单应用程序,因为我有一个菜单,其中一个项目是help. 它有一个子项About。正如您在许多应用程序中看到的,当您单击帮助时,会打开一个单独的对话框,其中显示信息。

I want something like that.

我想要这样的东西。

采纳答案by Thilina H

To add a menu to a Windows Form at design time Open the form you wish to add a menu to in the Windows Forms Designer.

在设计时向 Windows 窗体添加菜单 在 Windows 窗体设计器中打开要添加菜单的窗体。

  • In the Toolbox, double-clickthe MenuStripcomponent.
  • A menu is added to the form (displaying the text "Type Here"), and the MainMenu component is added to the component tray.
  • 在工具箱中double-clickMenuStrip组件。
  • 一个菜单被添加到表单中(显示文本“Type Here”),并且 MainMenu 组件被添加到组件托盘中。

Then you can do that as follows using click Event of that particuler subMenu item . Hint:Just click the subMenu item and rightclick->Properties..then you can find the Click Eventfor subMenuItem.

然后,您可以使用该特定子菜单项的单击事件按如下方式执行此操作。提示:只需单击子菜单项,然后rightclick->Properties.. 然后您就可以找到Click Eventfor subMenuItem

 private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
 {
    AboutWindow aboutWindow = new AboutWindow();
    aboutWindow.Show();
 }

回答by CompuChip

There is a standard about box in the templates, try Project / Add new item and look for About Box. You can show it like a regular dialog form, e.g. using new AboutBox(this). ShowDialog(); in the menu item click handler.

模板中有一个关于框的标准,尝试项目/添加新项目并查找关于框。您可以像常规对话框形式一样显示它,例如使用 new AboutBox(this)。显示对话框();在菜单项单击处理程序中。

回答by Tafari

Looks like you have not been searching for long, here it goes just add one using predefined template:

看起来您搜索的时间不长,这里只是使用预定义的模板添加一个:

Add item window

添加项目窗口

And you could possibly find this link useful:

你可能会发现这个链接很有用:

social.msdn.microsoft.com

social.msdn.microsoft.com

Quote from there:

从那里引用:

  1. Create a new windows form application
  2. In the "Solution explorer" ,left part of the screen , right click on the name of your windows application.
  3. Choose Add-->New item
  4. From the " Add new item window" choose "AboutBox" , name it "AboutBox1" , click on Add button. Now you have in your applicatoin two forms, "Form1" -- created by default by your project type and "AboutBox1" .
  5. Right click on the "Form1" and choose "Design View".
  6. Double click on the design sourface of form1.
  7. After that you will see this code:

    private void Form1_Load(object sender, EventArgs e)
    {
    
    }
    
  8. Add this code to your application, to look like this:

    private void Form1_Load(object sender, EventArgs e)
    {
        AboutBox1 a = new AboutBox1();
        a.Show();
    }
    
  9. Run the application.

  1. 创建一个新的窗体应用程序
  2. 在屏幕左侧的“解决方案资源管理器”中,右键单击 Windows 应用程序的名称。
  3. 选择添加-->新建项目
  4. 从“添加新项目窗口”中选择“AboutBox”,将其命名为“AboutBox1”,单击“添加”按钮。现在您的应用程序中有两个表单,“Form1”——由您的项目类型默认创建,以及“AboutBox1”。
  5. 右键单击“Form1”并选择“设计视图”。
  6. 双击form1 的设计界面。
  7. 之后你会看到这个代码:

    private void Form1_Load(object sender, EventArgs e)
    {
    
    }
    
  8. 将此代码添加到您的应用程序中,如下所示:

    private void Form1_Load(object sender, EventArgs e)
    {
        AboutBox1 a = new AboutBox1();
        a.Show();
    }
    
  9. 运行应用程序。

回答by Bereg Isztria

Before or after adding About Box to the project from the list of possible items, make sure that AssemblyInfo.cs is fulfilled with data.

在从可能的项目列表中将 About Box 添加到项目之前或之后,确保 AssemblyInfo.cs 已填充数据。

AssemblyInfo.cs in Solution Explorer Window

解决方案资源管理器窗口中的 AssemblyInfo.cs

In your project, click on Properties. Open AssemblyInfo.cs. This is the source of the info displayed in About Box.

在您的项目中,单击“属性”。打开 AssemblyInfo.cs。这是关于框中显示的信息的来源。