Loading

Windows Forms

Submitted by: 
Visitors have accessed this post 16341 times.


Windows Form

This tutorial is part of Database Programming Made Easy Series.

Without Windows Forms your application may look like a DOS application, running in a black and white screen without a Graphical User Interface.

This tutorial will discuss on how to use different controls like TextBox, Label, ComboBox, Button, CheckBox, and finally the ListView Control to access data from our database.

We will use the code from the previous tutorial so you will have a better understanding on how to integrate those codes in different controls mentioned above.
This tutorial is limited only to the use of various controls above. If you want to know better about windows form I suggest you buy a book called “Microsoft Visual Basic 2008 Step by Step”.

The Label and TextBox Control

Even if you are a beginner, most probably you know what a Label and a TextBox Control is. Our goal for today is to retrieve data and put it in a TextBox and give it a descriptive title in a Label Control.

In our previous example you retrieve the data and show its output in a temporary textbox called remarks. We do that just to simplify our code.

Now we will go to the heart of Visual Basic .NET. Let us create our first Windows Form project to be use through the rest of the tutorial.

  1. Click Start >> Programs >> Microsoft Visual Studio 2008 and choose Microsoft Visual Studio 2008. This will open the Integrated Development Environment of VB.NET.
  2. Click File >> New >> Project
  3. Select Windows Form the left sidebar and select Windows Form Application in the right sidebar and named the project as “WindowsFormTutorial” as shown below.

[inline:New Project Dialog.jpg=New Project Dialog]

  1. Finally press OK button.
  2. Add a Label and a TextBox control as shown in the video tutorial below.

As you may know that there are different ways to access or retrieve data from a database. One is by using a Data Reader and other is using a Dataset and Data Adapter.

You can also save the data back to the database using ExecuteNonQuery Command or by using again a Dataset and Data Adapter.

Previous: How to Modify Data Using Datasets and Data Adapters

Next: How to Retrieve and Save Data using TextBox Control




Comments

Hi, I am Li Chin here. After i download the TextBox Control.zip, i cant open the window from tutorial. It come out the message
Unable to read the project"WindowsFormTutorial.vbproj'.
Mai i know why can this happen?Thanks

admin's picture

May be your download is corrupted. Kindly download again and tell me if you still have problem.

Hi,

I was wandering if you can help me. I am writing a system based on your tutorials.
I have got to the point where I am wanting to write the data back to the db (MS ACCESS) but I keep getting this error:

NullReferenceException was unhandled: Object reference not set to an instance of an object.

please email me if you can: de[email protected]

admin's picture

Show me the code that has an error.

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.