用C#开发Windows应用程序

To develop windows application, we need to using studio and follow some steps:

开发Windows应用程序 ,我们需要使用studio并遵循一些步骤:

Step 1) First of all we launch visual studio.

步骤1)首先,我们启动Visual Studio。

Develop a windows application in C# 1

Step 2) Goto fie menu and select new project.

第2步:转到菜单,然后选择新项目

Develop a windows application in C# 2

Step 3) Now we select "Visual C#" from left panel and select "Windows Forms Application" and give appropriate name to our application. Here I provided name "MyWinApp".

步骤3)现在,我们从左侧面板中选择“ Visual C#” ,然后选择“ Windows Forms Application”,并为我们的应用程序指定适当的名称。 在这里,我提供了名称“ MyWinApp”

Develop a windows application in C# 3

Step 4) Then A default generated form will appear in our application, like this:

步骤4)然后,默认生成的表单将出现在我们的应用程序中,如下所示:

Develop a windows application in C# 4

Here we have following things:

这里有以下内容:

  1. ToolBox

    工具箱

    It contains tool to develop the application.

    它包含用于开发应用程序的工具。

  2. Solution Explorer

    解决方案资源管理器

    It contains our project detail; it shows all files related to our project.

    它包含我们的项目详细信息; 它显示了与我们项目相关的所有文件。

  3. Property window

    属性窗口

    Using property window we can change the properties of controls which are used in our application.

    使用属性窗口,我们可以更改应用程序中使用的控件的属性。

Building the solution

建立解决方案

We can build our project or solution using build menu or shortcut key: Ctrl + Shift +B.

我们可以使用构建菜单或快捷键Ctrl + Shift + B构建项目或解决方案。

Execution of Application

执行申请

We can execute our application with or without debugging. Here, we use debug menu or it can also be done by using shortcut key: F5 or CTRL+F5.

我们可以在调试或不调试的情况下执行我们的应用程序。 在这里,我们使用调试菜单 ,也可以使用快捷键F5CTRL + F5来完成

通过单击按钮控件,设计一个应用程序以在MessageBox上显示“ Hello World”消息 (Design an application to display "Hello World" message on MessageBox by clicking on button control)

First of all, we create a windows application. And then drag and drop a button from toolbox to container form.

首先,我们创建一个Windows应用程序。 然后将一个按钮从工具箱拖放到容器窗体。

Develop a windows application in C# 5

We can change the name, color and text etc of any control using property window, here we change our form text to "My First Windows Application" and button text to "Click Me".

我们可以使用属性窗口更改任何控件的名称,颜色和文本等,这里我们将表单文本更改为“我的第一个Windows应用程序” ,将按钮文本更改为“点击我”

Now, we wrote code on button's click event, we can generate sample code for click event by "double click" on the button. Then the generated code will we like this:

现在,我们在按钮的click事件上编写了代码,我们可以通过“双击”按钮来为click事件生成示例代码。 然后生成的代码将如下所示:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyWinApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}

Here button1_Click function will use as a click event, here we can write code what we want to do on click event on the button. Now we wrote code to show MessageBox to display "Hello World".

在这里, button1_Click函数将用作click事件,在这里我们可以编写代码,以对按钮上的click事件进行操作。 现在,我们编写了代码来显示MessageBox来显示“ Hello World”

private void button1_Click(object sender, EventArgs e)
{
     MessageBox.Show("Hello World");
}

Execute application using CTRL+F5. Here is the output after clicking on the button "Click Me":

使用CTRL + F5执行应用程序。 这是单击“ Click Me”按钮后的输出

Develop a windows application in C# 6

翻译自: https://www.includehelp.com/dot-net/develop-a-windows-application-in-c-sharp.aspx

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值