I've created a small HTML/JavaScript based mini-web app that reads data from an XML file.
Now, I need to create an offline WinForms editor for this XML file. I'm fully aware that using an XML file to store data in the fashion that I do is far from ideal, but the requirements are such that I can only use static files for the web site, though the XML file can be replaced when it is updated.
The mini-web app allows a customer that is buying a remote car starter to select the make, model and year of their vehicle and be shown a list of additional components that are required for the installation. This data is represented in XML as a <vehicle>
element with attributes representing the make, model, year, as well as attributes for each of the types of components.
The requirements for the editor are:
- Display vehicle records in a grid
- Allow autocomplete in each column based on values already entered
- Allow row filtering based on any combination of columns
I've tried the following:
- Using DataGridView and databinding, but databinding/datasets/etc don't seem to want to play nice easily with XML files as the data source. I gave up after wrestling with this for several hours
- Creating my own custom "row" control and inserting an instance for each element into a Panel control. Since there are several hundred vehicle records, this is a non-starter for performance reasons.
I'm generally a web guy, so this WinForms stuff is uncharted territory for me. What is the easiest way to accomplish the requirements for this editor?
Rather than creating a UserControl that incorporates a large number of smaller UserControls for representing each element, I think the sanest approach is to encapsulate the logic for visually representing the elements as classes that are responsible for rendering their data onto a single graphics surface (as opposed to encapsulating the logic in UserControls).
Since you've already created a "row" control (with editing capabilities, I presume), you can still make use of this by creating an instance of it and "floating" it over your control when the user clicks on it.
This earlier answer to a somewhat similar question:
Need help creating control to display data
shows the basic principle. You could use this approach to edit extremely large XML documents with only two controls being instantiated at any one time.