C#-Windows Programming Developing GUI Application Using WinForms
Assignment 1:
Title:-Create a windows form Applications to demonstrate the controls and its events?
Description:-
Create a Project and named as "ControlsDemoApp" and add a form to the project and named as [Link] and drag
and drop a link label on to form and goto properties window and click on events icon and generate linklabel clicked
event and provide a path where it should redirect. And next drag and drop three [Link] the first textbox and
generate form_load event to the textbox, initialize string collection and declare Autocompletestringcollection add
bind collection to the sc and set the properties to the [Link] the second textbox generate
keypress event as mentioned above and compare the input from the ascii values of numbers if the input is correct
then set [Link] to true(i.e display characters in the textbox).To the third textbox generate keydown event write
code for the when user click on ctrl+A in the textbox then display an message in the message box like you pressed
ctrl+A is [Link] the fourth textbox generate validating event and write code to validating the textbox should not
be [Link] display the error message use errorprovider.
Sample I/O:-
1
C#-Windows Programming Developing GUI Application Using WinForms
Assignment 2:-
Title:-Create a new Windows Application and named it as to move the items from one Listbox to another Listbox
and viseversa.
Create an application used to show the usage of listbox control. Create a windows form application and
create a form that contains drag and drop two listboxes and four buttons on and change the id of
textboxes and listbox.
First button is used to move one item from Listbox1 to Listbox2,Second button is used to move one item
from Listbox2 to Listbox1, third button is used to move all the items Listbox1 to Listbox2 and finally the
fourth button is used to move all the items from Listbox2 to [Link] below table shows the
description about buttons and textboxes
Control Text Name Additional Properties
Items Collection
[Link]
ListBox1 lb1
C#.NET
[Link]
2
C#-Windows Programming Developing GUI Application Using WinForms
SQL
C++
SHAREPOINT
MVC
PHP
ListBox2 lb2
Button1 > btnSelect
Button2 < btnRemove
Button3 Select All btnSelectAll
Button4 Remove All btnRemoveAll
In the first button i.e btnselect_clik event write code to move data from one Listbox1 to another Listbox2
i.e when user click on button add data to the second Listbox using Add() method and remove item form
Listbox1 using Remove() method.
To the second button btnremove_click write code to remove data from Listbox2 and add data to the
Listbox1 using Add() and Remove [Link] the third textbox btnselectAll to move all items from one
Listbox1 to Listbox2 first count the number of items in the Listbox1 using count() method and add item to
the Listbox2 using AddRange() method then next clear the Listbox1 using clear() method.
Repeat the same process to the btnRemoveAll_click event to move items from one Listbox2 to the other
Listbox1 if there are no item available display error message using [Link]() method.
Sample I/O:-
3
C#-Windows Programming Developing GUI Application Using WinForms
4
C#-Windows Programming Developing GUI Application Using WinForms
Assignment 3:-
Title:- Create a Windows application to show the images in the PictureBox one by one(Using two buttons Preview
and Next).
Description:-
Create a windows form application using named it. Design the form with one label, one texbox,one button,
pictureBox control and two buttons to the previous and next.
Create an array list. In the form load event set visible=false to the previous and next buttons. In the
btnbrowse_click event.
Drag and drop fbdImageFolder dialog box on form to browse the images .Store the fileinfo path in the
textbox. Using GetallFiles() method to raed akll the images in the folder.
Read images one by one using for each loop and compare file extension using file and Add list to the
collection and increment the count value by one.
After read all the image set the property of next, previous buttons to true.
In the previous and next buttons click events write code to display the images until less than or equal to
count if it is less than count value then set enable property to false.
Repeat same process to the btn_previous button .
Browse the Folder containing Images , so that you can view the images one by one by clicking on the
Previous and Next buttons.
Sample I/O:-
5
C#-Windows Programming Developing GUI Application Using WinForms
Assignment 4:-
Title:-Create an application to show the status of Progress Bar by percentage and also by using UserControl.
Description:-
Create a windows Application named ProgressBarWinApp.
Create a user control. Right click on the project Add New Item Select UserControl from the template
and name it as [Link]
Design the form as follows:-
6
C#-Windows Programming Developing GUI Application Using WinForms
Control Text Name Additional Properties
ProgresBar pbBar
Label1 lblProgress
Add a new form to the project
In the ToolBox at the top most you will find ProgressBarWinApp Components, you will find the
Usercontrol Progress. Just drag and drop the control on to the form and name it as ucStatus.
Add the Button control named btnStart to start the Progress.
Add the timer Control named as tmrIncrementBar, which is used to set the timer for the Progressbar. In
the Properties set as Interval:1000.
Sample I/O:-
Assignment 5:-
Title:- Create an application to change the details and the pictures of the mobile based on the Trackbar scroll.
Description:-
Create a new Windows Form Applications named it as "TraceBarWinApp".
Right click on the project->Add->New Folder named Images. Add some Images related to mobiles.
Design the form as below
7
C#-Windows Programming Developing GUI Application Using WinForms
Control Text Name Additional Properties
Group Box
Mobile Description
Label Make:
TextBox txtMake
Label Model:
TextBox txtModel
Label Price:
TextBox txtPrice
Label Year
TextBox txtYear
PictureBox pctMobilePicture
Minimum: 1
TrackBar trbSlider
TickStyle: TopLeft
Right click on form and click on view code and copy the below code
Create Object that stores information about each Mobile to store the values for the controls of the form, in
the top section of the file, create a managed structure named ListOfMobiles as follows
8
C#-Windows Programming Developing GUI Application Using WinForms
Declare managed array of ListOfMobiles and Intialize the array and the slider.
In the form_load event declare one string variable "path" and use "[Link]" to get the
path i.e running at exe.
When we slide the track bar, we will update the values of the selected Mobile
and we will call the OnPaint() event of the form to change the picture of the
Mobile. Handle the OnScroll event.
Raise the event txtSlider_scroll and get the index of current value of the trackbar -1.
Based on the current index, retrieve the value of the current mobile and assign each to the corresponding
control.
Raise the event btnclose_click write code to close the form using close().
Sample I/O:-
Assignment 6:-
Title:- Create a Windows Application to show the Countries and their States in the Treeview form and read all the
items into the Listbox and also get the selected item in the textbox.
Description:-
Create a new windows form application and Design the form as follows:
9
C#-Windows Programming Developing GUI Application Using WinForms
Control Text Name Additional Properties
TreeView tvCountries
ListBox lbItems
Button Clear btnClear
Button Get All btnGetAll
TextBox txtName
Right click on project and add new folder Images. Add some images which are used to set for rootnodes,
childnodes and sibling nodes.
Setting the images for the Imagelist. Which will be set to rootnodes,childnodes,siblings nodes.
Create a newnode using Treenode.
Create a child nodes for the root node.
Create siblings nodes for the child nodes.
Create a satck in the nodestack and push data in to the treeview node.
10
C#-Windows Programming Developing GUI Application Using WinForms
In the btnGetAll_Click() list all the nodes of [Link] read allnodes data using foreach loop of type
Treenode.
In the lblitems_SelectedIndexedChanged event get selected item and assign it to thetextbox text property.
Finally in the btnClear_click the write the code to clear all the elements using Clear() method.
Sample I/O:-
11