Resources and Settings Sample
This sample demonstrates how to manage resources and settings for an application by using the My.Settings object, the My.Resources object, the Project Designer, and the Resource Editor.
To get samples and instructions for installing them
Do one or more of the following:
On the Help menu, click Samples.
The Readme displays information about samples.
Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.
Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.
For more information, see Visual Studio Samples.
Security Note: |
---|
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties. |
To run this sample
Press F5.
Each time that you run the application, a different background is displayed.
Demonstrates
A setting is used to keep track of the number of times the application has been run. Each time the application runs, the setting is examined, and one of several available desktop images is selected based on that number. Consequently, every time that you run the application, you see a new background.
The code resides in the SetBackground method of Form1 and in the application startup and shutdown events, which are handled in My Project\MyEvents.vb. To view this file, double-click My Project in Solution Explorer. On the Application panel of the Project Designer, click the View Application Events button.
Settings are created and modified on the Settings tab of the Project Designer. There are two types of settings: application and user. Application settings are those with values that are common to all instances of the application. User settings are created and modified for each user. In this sample, the setting that persists the number of times an installation of the application has been executed is a user setting.