C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Building Windows Application (Address Book) - Part I


Posted Date: 25 Apr 2004    Resource Type: Articles    Category: .NET Framework
Author: Sadha SivamMember Level: Gold    
Rating: 1 out of 5Points: 10



Building Windows Application (Address Book)

Building the User Interfaces

Initially lets build, some of the forms, then we will write the code to
implement various functionalities of the Address Book.

First lets start with building the Login Page of the Address Book.

Designing the Login Page.

When we talk about the login page, we should keep in minds the
following things.


  • It should ask for the user name and password

  • Where the password should be taken in the encrypted format.

  • Should have a Login and Cancel button,
    where On Clicking the Login should check for the existence
    of the user and log into the Address Book.
  • If the user clicks the cancel button, we should shut down the
    Address Book.

  • Form should not be resizable

  • Form should be in the screen center



Now Lets get into building a Login screen.

Before creating the form, we should create the project. Open the Visual
Studio.Net IDE and create a new project called "AddressBook".

Then Right click on the Project in the solution explorer and add a new
form called
FrmLogin.


Note:
When developing an application we should follow the name conventions
strictly.

Some of the naming conventions that I am going to use through out the
project,

Form - Starts with Frm
Button - Starts with btn
Textbox - Starts with txt
Main Menu - Starts with mmnu
Context Menu - Starts with cmnu
Label - Starts with lbl
Panel - Starts with pnl
Link Label - Starts with lnk
Check box - Starts with chk
Radio Button - Starts with rdb
Group Box - Starts with grp
Data Grid - Starts with drd
Combo box - Starts with cbo
Timer - Starts with tim
Tool Tip - Starts with tlp
Error Provider - Starts with erp
Help Provider - Starts with hlp
Integer - starts with int
String - Starts with str

Apart from this, Each word in the Class names will begin in the Captial
Letter, for the object, variables and functions we will be using
capital letters for all the word in the name other than the first word.

We will not be having the underscore in names. All local variables will
begin with an under score (_).

Though VB.NET is not case sensitive, Lets try to follows these naming
conventions strictly. You may use your own style of code. But everywhere
you should follow the same naming conventions.

For more information, see Best Practices





Note for the VB Programmer

Now, if you see the code of the FrmLogin class, you may find it a little different. Because you will be finding a class declared as FrmLogin and System.Windows.Forms.Form class is inherited.

Form class contains all the functionalities and properties of a form, so when a class extends the Form class, inherits all the functionalities of the form and the class by itself becomes a Form class by itself. We are defining "is a" relation ship here. (VB.NET utilizes the OOPS concept Inheritance fully.)

Now lets get back to the development of the Address Books' login form.

Now the form is added, we need to set the size and make the form not resizable at the run time. This can be done in two ways. I will tell you both the ways, you can try both of them and implement which ever you want.

By using the Maximum and Minimum Size

We have two properties called MaximumSize and MinimumSize, which defines the maximum size and minimum size of the form that can be resized at the run time. By assigning both the properties two the same value, we can make the form not resizable at the run time. (We should set the MaximumSize, MinimumSize and Size properties to the same value).

By setting the FormBorderStyle Property

We can disable the form resize by setting FormBorderStyle property to FixedSingle (Fixed3D, FixedDialog, FixedToolWindow can also be used, try using them and find the difference between them yourself).

Note:

For both the ways we need to set the MaximizeBox and MinimizeBox properties to false. By setting any one of the properties to false will disable the corresponding button, if both are set to false the removed from the form.

But, I am going to go with the second way of doing it because it reduces the steps. I need to set only the FormBorderStyle. (by using the FixedToolWindow in the FormBorderStyle, we need not use the MaximizeBox and MinimizeBox properties.)

Now set the Form Border Style property to FixedSingle and set the MaximizeBox, MinimizeBox properties to false.

Setting the Startup Position

Now, we need to set the startup position to the center of the screen, This can be done by setting the StartPosition property of the form to CenterScreen.

Now we will design the form.

Designing the form

We need to have two TextBox (one for User name and one for Password), two Label (to display messages), two Buttons, one ErrorProvider, one HelpProvider and one ToolTip control.

If you see the designer window, ErrorProvider, HelpProvider and ToolTip will be placed in the panel at the bottom as shown in the figure below.

All the control, which will not be visible in the runtime, will be displayed in that panel.

Controls and its properties.
(change the following properties)
TextBox Controls
Text box for Login Name

  • Name - txtLogin

  • BorderStyle - FixedSingle

  • Text - ""



Text box for the Password

  • Name - txtPass

  • BorderStyle - FixedSingle

  • Text - ""

  • PasswordChar - "*"


Label Controls
Label to display Login Name

  • Name - lblLogin

  • Text - "Login Name"


Label to display Password

  • Name - lblPass

  • Text - "Password"



Button Controls
Login Button

  • Name - btnLogin

  • Text - "Login"


Cancel

  • Name - btnCancel

  • Text - "Cancel"



ErrorProvider Control

  • Name - erpLogin



ToolTip Control

  • Name - tlpLogin



HelpProvider Control

  • Name - hlpLogin



Now we have added all the controls required for the login screen. Place the text boxes, labels and buttons properly.

Note for the Vb6.0 Programmer:
In VB6.0 we had Caption property for the form, Label and Buttons, they are now in VB.NET replaced with Text property. Not only for Form, Label and Button controls, all the controls, which had Caption property, are now replaced with Text Property.

Now we have designed the form. Let see how to set the Tool Tip text for the control. In VB6.0 we need to set some text which is to be displayed in the ToolTipText Property. But that property is removed for all the controls. Instead we need to add a ToolTip control, which is going to manage the Tool Tip text for all the controls.


Upon adding the ToolTip Control, for all the control we get one more property called "ToolTip on Tool tip control name". There can be en number of ToolTip control and we will have same number of such properties for all the controls.

Now lets see how to set the ToolTip text for our controls. Select the txtLogin TextBox in the property window, we will be getting a property called "ToolTip on tlpLogin" ,(since we have added and named it as tlpLogin) set the message to be displayed in that property.

Similarly, set the ToolTip for all the other controls.

We will stop our development of "Address book" up to this now, in the next section of article we will see the remaining part of the development of Login Form and the development of Splash Screen.

We will also cover Help Provider, Error Provider control and setting the Tab Order in my next section of the article.

If you have any queries, doubt or suggestion to improve, please drop me a mail at sadhasivam1981@yahoo.com and sadhasivam1981@hotmail.com.

Visit http://sadhasivam.t35.com to know more about me.



Responses

Author: Dessi Bravo    07 May 2005Member Level: Bronze   Points : 0
I see that you started the login design form. However, do you have the code for the login page. I am using the Access Database instead of the Sql Database. I would like to learn how to code for the Access database when the login form design is finished.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Building Windows Application using VB.Net
Previous Resource: Building Windows Application (Address Book) - Part II
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use