简体   繁体   English

C#Visual Studio打开新窗口

[英]C# Visual Studio Open New Window

I am new to C# and Visual Studio, But I started a little project that opens a main window and shows a table. 我是C#和Visual Studio的新手,但是我开始了一个小项目,该项目打开一个主窗口并显示一个表。 The Presenter of the window contains an Observable: 窗口的Presenter包含一个Observable:

public ObservableCollection<FruitsPresenter> Fruits { get; set; }

This collections contains information about some fruits. 该集合包含有关某些水果的信息。 Then It shows a table of all i'ts content. 然后,它显示了所有内容的表格。 I made a button that supposed to open a new window and create a 'entry form' that will ask for information and then add to the collection a new item. 我做了一个按钮,该按钮应该打开一个新窗口并创建一个“输入表单”,该表单将询问信息,然后向集合中添加一个新项目。

I couldn't manage to do it. 我无法做到这一点。 Any help? 有什么帮助吗?

Adding a new form and opening it is very simple in C#/Visual Studio. 在C#/ Visual Studio中,添加新表单并打开它非常简单。

Do the following: 请执行下列操作:

  1. Add a new form to your project: 将新表单添加到您的项目中:

    Do this by right-clicking your project and choose: Add -> Windows Form. 通过右键单击您的项目并选择:Add-> Windows Form来执行此操作。

  2. Name the form 命名表格

  3. Create new instance of form and call form: 创建表单的新实例并调用表单:

Go to the location where the new form should be called from. 转到应从中调用新表格的位置。 Add following code there: 在其中添加以下代码:

NewForm newFrm = new NewForm();
newFrm.Show();

New form will be visible when application calls code above. 当应用程序调用上面的代码时,新表格将可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM