Tuesday, February 25, 2014

Windows Application - Part - 2

Whatever the control it was every control has 3 things in common.
1.      Property: - these are attributes of a control which have their impact on look of the control. Eg: Width, Height, Back Color, for color etc.

2.      Method: - these are action performed by the controls eg: Clear(), Focus(), Close() etc.

3.      Events: - these are time period which specify when an action has to be perform. Eg: Click Load, Keypress, mouse over etc.

Note – All the controls we are going to work with or derived from a default parent i.e. class control, which contains the properties methods and events which are common for all the controls like: Form, Button, TextBox etc.

Que. How to develop a windows application?
Ans. if we want to develop a windows application, the base control which has to be created first is – Form. To create it we follow the blow process.

Step 1: Define a class inheriting from the predefined class form so that the new class is also a form.
Step 2: now to run the form we have created, create an object of it and passed it as parameter to the rum method of application class, which is responsible in execution of a windows application.

Que. from where can we develop a windows application.
Ans. we can develop a windows application in two different ways:
        I.            Using notepad following the above process.
      II.            Using windows forms application project template, under Visual Studio.

Developing windows application under notepad: - open notepad  write the following code init then save, compile and execute
using System;
using System.windows.forms;

public class MyForm : Form
{

static void Main()
 {
   MyForm f = new MyForm ();
    Application. Run(f); 
 } 
 }

.      Developing windows application under Visual Studio:- To develop a windows application under visual studio,
  • Open new project window select windows form application project templates and specify the name to the project, eg- WindowsProject. 
  • By default the project comes with two class’s init.
  • Program.cs
  • Form1.cs
  • The execution of windows application starts from the static class program, under this class we find a main method creating the object of Form class that has to be executed.
Eg: Application. Run(new Form1());
  • Form1.cs is the file in which the class Form1 is defined inheriting from pre-defined class Form and this is the class that has to be executed.

    eg: public partial class Form1 : Form
  • Windows application develops under Visual studio has two places to work with.
  1. Design view
  2. Code view 
  • Design view is the place where we design the application; this is accessible to both programmers and end users.
  • Code view is the place where we write the code for execution of application, this is accessible only to programmer.

Note- because of the design view, what VS provides it is known as WYSIWYG editor- (What You See Is What You Get)

No comments: