Creating Windows Forms Applications

It is often easier to demonstrate code by running it as part of a Windows application than through a console window or via a command prompt. You can do this using user interface building blocks to piece together a user interface.
The following Try It Out shows just the basics of doing this, and you ’ ll see how to get a Windows application up and running, without a lot of details about what the application is actually doing. Later you take a detailed look at Windows applications.
1. To create windows forms application select file new project from file menu as :

2. After Creating project Form1.cs will be created automatically, Drag a button from toolbox to form1.cs in design mode.
3. double click the button and form1.cs will be opened in as code file. Write following code as :


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 WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
            MessageBox.Show("Hello Windows application");

Debug program by pressing F5 or select Start debugging from menu, press button1 and the message box with “Hello Windows application” will be displayed”


You may also like...

No © Loop and Break