The beginning. My first Windows Forms Application (C#)

I’ve been taking a course in C# programming for a couple of weeks and we have recently started to work with Windows Forms Applications.

My homework was to create an application which adds information of a person (name, gender and some qualities) to a list, as well as having the posibility to delete all the items from it or just the last one. So here it is!

Firstly, I’ve created a new project in Visual Studio as a Windows Forms Application (using visual C#). All I had to do in the beginning was to drag and drop in the form the elements from the toolbox I needed to use and arrange everything just how I wanted. I used two labels, two textBoxes, two groupBoxes ( one with radio buttons and the other one with checkBoxes), a listBox and three buttons. I changed the text of the elements from their properties.

Secondly, I had to create an event for each button. This means I had to ‘tell’ each button what to do when it is clicked on. For this, I clicked on the little lighting in the properties of each button and then double-clicked on the word click . *so many clicks o_o * Thus I created three events, for three buttons.

For the first one, I wrote a code in which the program takes the information from the text boxes and the group boxes and writes them on the list. It uses a string item which takes the data from the textBoxes, the checked radio button and checkBoxes and then is added to the listBox.

button1

The second button removes only the last item from the list.

button2

And lastly, the third button deletes the entire list.

button3

Moreover, I wanted it to look a little bit more colourful, so I changed the form background from its properties. And I also enabled the horizontal scrollbar of the listBox.

And that’s it! :)