Professional Documents
Culture Documents
Unit Ii Windows Forms Windows Forms Is A UI Framework For
Unit Ii Windows Forms Windows Forms Is A UI Framework For
You will see a Form Designer displayed in Visual Step 3) In this step, we will now add a label to the
Studio. It's in this Form Designer that you will start Form which will display "Hello World." From the
building your Windows Forms application.
toolbox, you will need to choose the Label control ● The properties panel also shows up in Visual
and simply drag it onto the Form. Studio. So for the label control, in the
properties control, go to the Text section and
enter "Hello World".
● Each Control has a set of properties which
describe the control.
Once you drag the label to the form, you can see the
label embedded on the form as shown below.
If you follow all of the above steps and run your
program in Visual Studio, you will get the following
output
Output:-
To go to the properties of a control, you need to In the output, you can see that the Windows Form is
right-click the control and choose the Properties displayed. You can also see 'Hello World' is
menu option displayed on the form.
Label Control
Textbox
Once you make the above changes, you will see the Step 2) Once the text boxes have been added, go to
following output the properties window by clicking on the textbox
control. In the properties window, go to the Name
Output:- property and add a meaningful name to each textbox.
For example, name the textbox for the user as txtUser
and that for the address as txtAddress. A naming
convention and standard should be made for controls
because it becomes easier to add extra functionality
to these controls, which we will see later on.
Step 2) Once the list box has been added, go to the
properties window by clicking on the list box control.
Once you make the above changes, you will see the
following output
Output:-
RadioButton
A Radiobutton is used to showcase a list of items out 1. First, you need to change the text property
of which the user can choose one. Let's see how we of both Radio controls. Go the properties
can implement this with an example shown below. windows and change the text to a male of
We will add a radio button for a male/female option. one radiobutton and the text of the other to
female.
2. Similarly, change the name property of both
Step 1) The first step is to drag the 'radiobutton'
Radio controls. Go the properties windows
control onto the Windows Form from the toolbox as
and change the name to 'rdMale' of one
shown below.
radiobutton and to 'rdfemale' for the other
one.
One you make the above changes, you will see the
following output
Output:-
From the output, you can see that when any item
from the list box is selected, a message box will pops
up. This will show the selected item from the listbox.
Output:-
Tree and PictureBox Control 1. Go to the properties toolbox for the tree
view control. Click on the Node's property.
There are 2 further controls we can look at, one is the This will bring up the TreeNode Editor
'Tree Control' and the other is the 'Image control'.
2. In the TreeNode Editor click on the Add
Root button to add a root node to the tree
collection.
3. Next, change the text of the Root node and
provide the text as Root and click 'OK'
button. This will add Root node.
PictureBox Control
Once you have made the above changes, you will see
the following output.
Output:-
One you make the above changes, you will see the
following output
Output:-