I have开发者_高级运维 4 WinForm app. Form1 inherits from baseForm, Formv2 inherits from Formv1, v3 from v2, v4 from v3. There are about 2 thousand controls spread across many tabs that contain tabs.
This is really killing Visual Studio 2008, frequently causing it to crash, and just terrible performance in general.
I want to create a FormV5 that inherits only from baseForm but contains all the visual layout of formsv1 through v4 (all of them), (there are no controls on baseForm).
The differences from form to form are mostly adding new controls, with some older controls having to be moved or hidden, and or a few labels changed here and there.
Can anyone suggest a programmatic way to do this? Like some way to use reflection or something at runtime on formV4 to generate the code (dump formV4 controls, layout and properties) i can cut and paste into the formV5.designer.vb.file?
(Note, this is an enterprise project that is about 5 years old, and everytime we make a change we need to push it out to all our clients (hospitals). We have no automated testing or unit tests, so i kinda gotta get this right :) )
thanks jonathan
Merging all of the actual formlogic virtual members, should manually manageable.
If the layout from Form1 to Form2 to Form 3 to Form 4 is mostly additive (adding new controls) and is not a whole lot of other manipulations (changing a whole lot of existing controls), I would separate it as follows:
Put all of the global form settings (like backcolor, etc. - not the layout of the child controls) in a base form. From your description it sounds like this is already in baseForm.
Put the layout of all of your child controls for Formv1 in a UserControl. This UserControl would act as a container of all of the controls that were previously on the form.
- Make a second UserControl that inherits from the first UserControl. Add new controls as neccessary.
- Make a third UserControl that inherits from the second UserControl. Add new controls as neccessary.
- Make a fourth UserControl that inherits from the third UserControl. Add new controls as neccessary.
- Make a Form1 that inherits from baseForm and has the first UserControl on it.
- Make a Form2 that inherits from baseForm and has the second UserControl on it.
- Make a Form3 that inherits from baseForm and has the third UserControl on it.
- Make a Form4 that inherits from baseForm and has the fourth UserControl on it.
The advantage of this idea is that you can change settings on the base form to your heart's content (default font, default forecolor, etc.) and at the same time incrementally change the layout of the controls through the use of the UserControls.
精彩评论