winform form build using data-driven controls
Posted on 2006-05-31
I would like to design a process that will read a sql database to identify what controls go on a form for a reporting process. The things that I see stored in the database table are the controls needed, what order they should be displayed in, the text label that should be associated with the control, and the crystal report parameter they are to be associated with as well as some other pertinent information for processing. That's what I have in mind so far.
I would then pull the list of controls in through a dataset ordered by the order specified in the table for display, loop through and dynamically position them on the screen. I then need to gather the information entered in the control and send it with it's crystal report parameter to our crystal reports process to generate the report.
The concept being that the user can specify the parameters in a table and the screen would build itself so if they have a new report, it doesn't necessarily need coding changes.
So this is the code I have to dynamically add it but in a non-data driven way.
CreditAcctEntry ctrlCreditAcctEntry = new CreditAcctEntry();
ctrlCreditAcctEntry.Location = new Point(12, 126);
What I'm trying to figure out is a syntax to make ctrlCreditAcctEntry a constructed name of sorts if that makes any sense...meaning I pulled from the table that I need to put CreditAcctEntry control on the screen. Theoretically I may have multiple of the same control with different text associated with parms...for instance, a begin credit acct and an end credit acct. So to be completely dynamic, I need to be able to construct the name of the object (ie: ctrlCreditAcctEntry1 and ctrlCreditAcctEntry2) and then be able to reference it later, without a hardcoded name, for gathering the properties returned from it after data entry. Or maybe there is simply a better way to go about this and get the same results.
Any help you can give me would be greatly appreciated.