Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Application Settings in VB 2005  »  Create Settings
 »  Home  »  Windows Development  »  Visual Basic 2005  »  Application Settings in VB 2005  »  Create Settings
 »  Home  »  Windows Development  »  Win Forms  »  Application Settings in VB 2005  »  Create Settings
Application Settings in VB 2005
by Ged Mead | Published  11/09/2006 | .NET Newbie Visual Basic 2005 Win Forms | Rating:
Create Settings

Demonstration Settings

   As a demonstration task, we will add three new Settings. 

   The first will store a user's chosen user name, the second will save the user's choice of form color and the third will optionally allow the user to save the size of the form as the user's chosen values.

User Name

   Click on the first line of the Settings Grid and double click on the first item in the Name Column (which by default is named "Setting") to highlight it.  Now overtype "Setting" with "UserName".

   Leave the Type column item at the default of "String" and the Scope at the default of "User".

   All that remains is to add a default value for this string.  Type in the word "Anonymous".

   The screenshot below shows these steps completed:

   You might notice that the Settings are also displayed in a standard Visual Studio Properties Window at the bottom right of the IDE.   Settings can be edited in the normal way here as well as in the Settings grid.

Form BackColor

   To demonstrate saving a Setting of a different Type, the next line will be used to enter the details of the Form's BackColor.   The screenshot below shows the Settings used.  You simply click on the down arrow to the right of the Type and select System.Drawing.Color from the drop down list. 

  Click anywhere inside the Value cell and a small down arrow will appear.  Click this in order to view the standard three-tab color choices list.  

Form Size

   Finally, add a third Setting named FormSize, select the System.Drawing.Size Type from the dropdown list and type in your chosen values for width and height in the Value cell. 

   I have purposely made the form size quite small so as to encourage the user to change it and then save it.




Sponsored Links