This tutorial will show how we can use the many .NET Controls in a Windows Form and how we can use them to gather information from the user and provide more interactivity. VB version.

In this tutorial we are going to look at ways we can implement .NET Controls into a Windows Form and how we can code them to make them functional to our needs. We are going to see how to implement and utilize textboxes, buttons, radio buttons, a list box, and a combo box.
The resulting Form will look something like this:

First, we will start off by adding a button to initiate a Message Box that poses a question to the user. We simply drag a button onto the form, and create the event handler for its click:

In this block of code, we are making a Message Box appear as soon as the user clicks the button. The Message Box will have Yes and No buttons and ask if the user understands how it works. Then we capture the user’s answer, and display another Message Box dependant upon that answer.

Next, we will create a TextBox and a button. When the button is pressed, a Message Box will be displayed, with the data the user typed in. If no data was input, the user will be instructed to do so.

Next, we will add the Combo Box and add code to the SelectedIndexChanged event handler, and again, display a Message Box to the user, announcing the option they choose:

We can also add a List Box Control, a Text Box and a Button to let the user add their own items into the List Box. We do this simply with the following code:

We can also add another buttons allowing the user to clear the contents of the List Box:

Finally, we can add a bunch of Radio Buttons to allow the user to set the background color of the Form, from a pre-determined set of colors:

The entire code-behind will look something like this:

Download Source Files