In this tutorial, I will teach you how to populate data in a combobox using XML File and C#. This method has the ability to display the data from the XML file to a combobox. Hope this tutorial will help you with your current problem in programming. Just follow the instructions below.
Go to the solution explorer, right click the resources file and add new item.
Create an XML File named “country”.
Write the following codes for adding the content in the XML FIle.
- <Description>Belgium Francs</Description>
- <Description>Germany Deutsche Marks</Description>
- <Description>Spain Pesetas</Description>
- <Description>France Francs</Description>
Open Microsoft Visual Studio 2015 and create a new windows form application for c#.
Do the form just like shown below.
Press F7 to open the code editor. In the code editor, add a namespace to access the
Resources File .
- using LoadDataXML.Properties;
Create a method for filling the xml data inside the combobox.
Write the following code to execute the method that you have created in the first load of the form.
- private void Form1_Load(object sender, EventArgs e)
The complete source code is included you can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.