Ged Mead (XTab) is a Microsoft Visual Basic MVP who has been working on computer software and design for more than 25 years. His journey has taken him through many different facets of IT. These include training as a Systems Analyst, working in a mainframe software development environment, creating financial management systems and a short time spent on military laptop systems in the days when it took two strong men to carry a 'mobile' system.
Based in an idyllic lochside location in the West of Scotland, he is currently involved in an ever-widening range of VB.NET, WPF and Silverlight development projects. Now working in a consultancy environment, his passion however still remains helping students and professional developers to take advantage of the ever increasing range of sophisticated tools available to them.
Ged is a regular contributor to forums on vbCity and authors articles for DevCity. He is a moderator on VBCity and the MSDN Tech Forums and spends a lot of time answering technical questions there and in several other VB forum sites. Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, and DevCity.NET Newsletter Editor. He has written and continues to tutor a number of free online courses for VB.NET developers.
View all articles by Ged Mead...
Application and User Settings have been given a facelift in VB2005. One of the questions that has appeared in VBCity Forums many times over the past few years is the one where someone wants to know how to save user choices, UI settings or other small items of data that have been input by users. Traditionally, going back to Classic VB days this has been done by using the SaveSettings and GetSettings functions which access the Registry to write and read back the data.
This approach still works and can be used in all versions of VB.NET, including 2005. While it's not difficult to use, I've never thought of it as particularly intuitive either. So it's good to see that in Visual Studio 2005 there is a very easy to use visual feature available from the Project Properties tab. You are then able to navigate through the available settings in code with ease, thanks to the My.Settings feature.
The examples shown in this article are designed for Beginner Level developers as an introduction to the topic. Fire up a new VB 2005 Windows Forms Project and we'll put My.Settings through its paces.
Accessing the Settings Editor at Design Time
You can use the Settings Editor at design time to set up the names and Types of data for which you want to be able to store settings. To access this editor, use your favourite technique to get to the project's Properties window, e.g. by right clicking the project name and selecting "Properties":
or from the main menu:
The initial view of the Settings Tab in the Project's property Pages will look like this:
Creating new Settings is a very easy process as we will see.