(Resolved) Ideas on quicker way to create forms with many fields
Hello all,
Wondering if anyone has ideas on how to generate code for controls for forms with many fields.
These are for applications where the VB form needs to simulate an existing paper form with, say 50 fields on it; let's say they are checkbox items.
As you know, it is a tedious process to create this in the VS IDE: placing each checkbox on the form and entering the desired text for it as well as renaming it.
It would be nice if there was some kind of utility that could (say) take an Excel spreadsheet in with (say) two columns: CheckboxName and CheckboxText, and generate all or part of the code to create a VB form containing those checkboxes.
Any ideas?
Re: Ideas on quicker way to create forms with many fields
I don't know of an utility. If I had to create a multi button form I would use an int loop adding + 1 to the name and getting the size and position of the previous inserted control so I can place the current on the form. As you say this might be excel, it makes it easier to add the name and text as you already got them, put the excel columns to a list or dictionary or something similar and do a for each. The most challenging would be the position of the controls, if they reach the end of the form, if they start stacking to the right etc....
Re: Ideas on quicker way to create forms with many fields
Hi sapator, thanks for your response. I know this type of thing can be done at run-time by dynamically adding controls as you suggest. What I am looking for here is a "design time" solution - something that would generate code for the FormX.Designer.vb file, so once that file is updated, I could further manipulate the controls on the form etc. The "excel" or input file could have additional parameters for location (i.e. top and left).
Now that I am looking at a Designer.vb file from one of my projects, I suppose it would not be too difficult to write a stand-alone program that would read in an Excel (csv) file with the parameters I described, and generate code for the Designer.vb file to a text file, and from that text file copy and paste it into the real Designer.vb file in my project ...
Re: Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
BruceG
Now that I am looking at a Designer.vb file from one of my projects, I suppose it would not be too difficult to write a stand-alone program that would read in an Excel (csv) file with the parameters I described, and generate code for the Designer.vb file to a text file, and from that text file copy and paste it into the real Designer.vb file in my project ...
That’s what I was about to suggest…:D
Re: Ideas on quicker way to create forms with many fields
Re: Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
BruceG
Great minds ...
...and fools never differ. ;)
Re: Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
jmcilhinney
...and fools never differ. ;)
Oh??? How would you attack this problem? :D
Re: Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
BruceG
Great minds ...
The only thing I would do differently is that I’d create the entire Designer.vb file. No copying and pasting. Just change the name and put it in place of the original file
Re: Ideas on quicker way to create forms with many fields
Thanks .paul. - no need for nastiness here - job trying to get work done.
Re: Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
.paul.
Oh??? How would you attack this problem? :D
That wasn't a criticism of anything you've done here. It was just a joke (hence the wink) based on the full expression, as I've heard it: "great minds think alike and fools never differ".
Re: (Resolved) Ideas on quicker way to create forms with many fields
No offense taken then.
I have marked this as resolved, as I was able to write a quick utility to do what has been described (read in a csv file with the desired control types, names, text, etc.) and output the equivalent code that can be pasted into a designer.vb file. Not pretty or turn-key, but it works and will save tons of time for these types of customer requests ("hey, can you automate this form?" - a 1-page Word document, small font single-spaced with 100 items on it ...)
Re: (Resolved) Ideas on quicker way to create forms with many fields
You could probably make the process smoother by building it into a VS extension. It's a matter of whether it's worth the investment in time and effort to create that to save a bit of time on each occasion you want to perform this task.
Re: (Resolved) Ideas on quicker way to create forms with many fields
Quote:
Originally Posted by
jmcilhinney
You could probably make the process smoother by building it into a VS extension. It's a matter of whether it's worth the investment in time and effort to create that to save a bit of time on each occasion you want to perform this task.
That's a further step i could've suggested. I'd think it would be quite an improvement to create an entire Designer.vb file, or at least edit the existing one without resorting to copying and pasting manually.