Hi there, I have a large domain object (Data only) that follows a strict .xsd schema for validation. I'm trying to let the user edit/create this huge object using winforms but I'm not sure what's the simplest way to do so. I thought about 2 ideas: The first one is to bind the entire object to the different controls. The second one is to somehow dynamically create the different controls using the xsd schema (Which is kinda cool because I have about 60 different text boxes with all kinds of possible drop down answers). Is there any good way to do this? Thanks,
Not enough info. Seriously - this is NOT a programming question, it is a design (like interface design) question first, and a lot depends on the circumstances.
Example: if there are existing forms users fill out, following an approach of copying the form may be good - espeically if the paper form is still printed out and signed or something like that. Infopath (part of Office) is absed on this idea.
Then a LOT depends on the workflows involved.
I do not think there is a valid better / worse anwer from a purely technical point ignoring what actually is on the form.
You can add controls dynamically to a WinForm by adding them to the forms Controls collection. In addition you have container controls that can have their own child controls.
So depending on how many types of controls you need you could build the form dynamically by iterating through the schema, adding controls as needed and finally loading your data into the controls.
Loading the data would probably be the hardest part, but there are several ways to fix this. You could use data binding to an object that match your xsd schema, you could an xpath to your controls and iterate through them to load the data, and so on.
I don't think there is a standard solution for doing what you are after, but it is quite easy to implement dynamic forms in WinForms so it should be quite straight forward.
You can also have a look at the PropertyGrid control. It will automatically generate controls in a tree-like structure. I use it to allow user to edit configuration files (for example). The XSD.exe tool will help you create the objects structure needed for the PropertyGrid control.