0% found this document useful (0 votes)
3 views12 pages

03 Introduction Lab - Hello World

This document provides a step-by-step guide to creating a basic C# Windows application using Visual Studio. It covers project setup, form design, adding GUI elements, and writing code to display 'hello world' in a label. The guide emphasizes the use of the Solution Explorer and Properties panel to manage and customize the application components.

Uploaded by

nguyenyt2006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

03 Introduction Lab - Hello World

This document provides a step-by-step guide to creating a basic C# Windows application using Visual Studio. It covers project setup, form design, adding GUI elements, and writing code to display 'hello world' in a label. The guide emphasizes the use of the Solution Explorer and Properties panel to manage and customize the application components.

Uploaded by

nguyenyt2006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introductory Lab

A first C# windows application

1 START / programming -> Visual Studio


Create a new project

In Location: - browse to where you want to store your C# projects

In Name: - choose some name e.g. HelloWindowsWorld

Make sure “Close Solution” is checked

1
2
.2 Should display Form1 in design mode

Right click on the form and select “View Code” to see the code for the class.

3
The code should look something like:

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace HelloWindowsWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

It is a “partial class” because a lot of the code generated for class Form1 is hidden
from you in another file called [Link]. You can access this file from
Solution Explorer panel on the right. You may need to expand the [Link] node in
order to see it.

4
You shouldn’t normally need to edit the code in [Link].

In the Solution Explorer you can also see that another class file has been generated
called [Link]. If you look at the code for this you can see that it is the program
that creates and instance of Form1and runs it.

2.3 Select the [Link] design view (DoubleClick on the form).

If the Toolbox is not already on display select View->Toolbox. You can “pin” the
toolbox so it shows all the time

5
Click on “All Windows Forms” in the toolbox to display some standard GUI widgets.
Add a label and a button to the form by dragging them

6
7
8
Check if the Properties panel is not showing, Go to View->Properties Window

Use the Properties panel to change the text of the button to “click me”

9
Change the name of the label to lblHello

10
Select the button on the form.. Double click on it. This should show the code:

Inside the { } add in some code to display hello world in the label e.g.

[Link] = "hello world"; // This is an assigment

11
Build and run the program by clicking on the Start button at the top ( with a green
arrow )

12

You might also like