Mar 16, 2015
We create applications on a daily basis to meet our customers’ requirements; often the case will be to create a solution that can retrieve some information out of a data source, such as a database or an XML file.
When we create a solution that uses XML, not only can we save information about our entities, for example products or customers, but we can also save our applications configurations into the file.
By doing this, you can make sure that when the user loads the application you can apply these settings to the application, without the user needing to set it up again. To do this we can create an XML file.
To perform this, will have the following controls on your form:
- A ComboBox named cboxcolor
- A NumericUpDown named numwidth
- A NumericUpDown named numheight
- A Button named btnSaveconfig
- A few labels to describe the controls
By performing the following steps, we will create an XML file to save the configuration settings and then read the settings upon loading the form. (Below is the full XML file.)
- Make sure you reference the needed namespaces by adding it on top of your code System.XM
- First create a Method called applysetting to apply all the changes you made.
- Create a click event for the btnSaveconfig button,. This event will be used to write the XML file that contains the configurations settings and then apply it to the form.
- Add the following code to the btnSaveconfig click event. Read the notes on the code script for the explanations (prefixed with //.)
- Finally we need to load the settings from the XML file when the application starts up again.
- With all this in place you should now have an application that can save an XML file with configuration in the bin directory of your solution and also, read from that file to apply the given settings.
How do your Excel skills stack up?
Test NowNext up:
- Background images in OneNote 2013
- Using cultural networks within organisations to disperse information.
- Customise quiet hours with Windows 8.1
- Managing packages with NuGet
- Make life easier with LastPass
- Join text without using the Concatenate function in Excel 2013
- Ten classic business writing mistakes
- Directory Integration Tools – One wizard to rule them all!
- Excel Array Formulas (Part 1)
- YouTube Safety for Kids, and adults...
Previously
- The Spike
- Development Sideloading of Windows Store Apps
- HR and age discrimination
- Prototypal Inheritance in JavaScript
- Instant calculations in Excel
- The Best Excel Keyboard Shortcut
- Microsoft Dynamics - Maximum processing power!
- HR for Non-HR Managers: Is the HR function necessary?
- Indexed member initialisers in C# 6
- Top 10 posts you may have missed from February