How to use Window Form in C#

In this article, I will explain use window form in C#.
  • 2564

C# Windows Forms

  • GUI application will create starts with a form.

  • Windows Forms is a technique of creating computer applications based on the common language runtime (CLR).

  • Windows Forms application object are stored in libraries also called assemblies.

  • There are two broad categories of objects used in a Windows Forms application: the forms and the controls.

  • Windows Forms  offers a series of objects called Windows Controls or simply, controls. These controls are already created in the .NET Framework through various classes.

  •  Windows form is based on the Form class that is defined in the System::Windows::Forms namespace created in the System.Windows.Forms.dll assembly.

Example

The following example shows how to change the Title, BackColor, Size, Location and MaximizeBox properties of Form1.

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 WindowsFormsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            this.Text="This is the first window form. change properties by coding";

            this.Size=new Size(400,150);

            this.Location=new Point(400,400);

            this.MaximizeBox=false;

            this.BackColor = Color.Gray;

        }

    }

}

 

Output


window example.jpg

 

Further Readings

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2013 dotNetheaven. All rights reserved.