FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

C# Tutorial: How to create a window and controls

prabakar
3/27/2005 7:51:50 PM, Views: 1877
/*
* Program Desc:
*
* This is the program to create a Window using C#
* The window will contain a label and a button.
* While click the button the application will terminate.
*
* Author: Prabakar Devarajan [mail:prabakar_microsun@yahoo.com]   
* Copyright: Microsun Computer Solutions
* On:   10:00 PM 1/13/2005
*/
using System; //all data types and Application are here
using System.Windows.Forms; //the Form is here

namespace Microsun.MyWay.MileStone1
{

    public class WindowInCSharp : Form   //inheriting the Form
      {

         // Fields
         // Events
         
         // Properties         
            
            private System.Windows.Forms.Label lblOutput;
            private System.Windows.Forms.Button btnExit;
   
         //Constructor
         
            public WindowInCSharp()
             {
   this.lblOutput = new System.Windows.Forms.Label();
   this.btnExit = new System.Windows.Forms.Button();
   
   //form
   this.Text = "Hello World";
   this.ClientSize = new System.Drawing.Size(300,200);

   this.Controls.Add(this.lblOutput);
   this.Controls.Add(this.btnExit);

   //lblOutput
   this.lblOutput.Text = " Hello World ";
   this.lblOutput.Location = new System.Drawing.Point(100,100);
   this.lblOutput.Size = new System.Drawing.Size(80,20);
   
   //btnExit
   this.btnExit.Text = " Exit ";
   this.btnExit.Location = new System.Drawing.Point(100,130);
   this.btnExit.Size = new System.Drawing.Size(80,20);
   this.btnExit.Click += new System.EventHandler(this.btnExit_Click);

             } // constructor WindowInCSharp

         // Methods
      
         // Application Entry Point

          public static void Main()
            {
                  Application.Run(new WindowInCSharp());
            } // method Main

       //EventHandler of btnExit

            void btnExit_Click(object sender,System.EventArgs e)
   {
       Application.Exit();
   } // EventHandler btnExit_Click         

       } //class WindowInCSharp   

} //namespace Microsun.MyWay.MileStone1
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Not Yet Rated!
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
C# RSS Feed
prabakar
Most Popular Tutorial
Most Popular Solution
No Records!
Top Rated
No Records!
Top Rankers
Overall
1. prabakar (100)
Yearly -2008
No Rankings!
Expertsforge Sponsors
bnrtop