Beginning Visual CPP 2005 Express Part 4 - Online Article

Creating CLR Graphical Application

To create a new project

1. On the File menu, point to New, and then click Project....


2. In the Project Types area, click CLR, then in the Visual Studio installed templates pane, click Windows form Application.


3. Type WinformApp as the project name. When you create a new project, Visual Studio places the project in a solution. Accept the default name for the solution, which by default is the same name as the project. You can accept the default location, type in a different location, or browse to a directory where you want to save the project and click to ok.

4. A window with a form appears.


Using Solution Explorer

Solution Explorer allows you to work with files and other resources in your solution. In this step, you add a class to the project and Visual Studio adds the .h and .cpp files to your project. You then add a new source code file to the project for the main program that tests the class.

To add controls to the form

1. If the Solution Explorer window is not visible, on the View menu click Solution Explorer.

2. If the toolbox window is not visible, on the View menu click Toolbox.


3. Select label control from the toolbox and drag to the form.

4. Similarly click on to dateTimePicker and Button control from the toolbox and drag on the form.

To change properties of the form and controls

1. If the Property window is not visible, on the View menu click to Other windows->Properties window.


2. Select the form and change the name of the form to Date Changer under text property of Property window.

3. Similarly select the label and button and change the name of the label and button to choose a date and ok respectively under text property.


To Add coding

1. Double click on the ok button.

2. Under button_click() module type the following code.


3. Go to properties of date time picker control and click to value changed property and change the name to date time picker1.

4. Type the code under dateTimePicker1_valueChanged module as,

label1->Text=String::Format("New Date: {0}",dateTimePicker1->Value);

To Build the application

1. Click on build->build solution Output window will show the compiled solution.


To Debug the application

1. Click to Debug->Start Without Debugging

2. Windows Form appears.


To Run


Date appears on the label.

Click to OK to exit.

About the Author:

No further information.


No comment yet. Be the first to post a comment.