Reputation: 1332
I'm using form inheritance in my project. I design a base form, and then create forms that inherit it and go from there.
Here's the problem. If I change the width of the base form, the inherited forms don't get their widths updated.
Say my base form started at 820 width. I create an inherited form, it has 820 width. I update the base form to 800 width, inherited form stays 820. Yet, if I add a button to the base form, or make a number of other changes, those are reflected in the inherited form usually without issue.
It doesn't only apply to form width, I've run into this a few times.. but this is the current issue I'm having. Any anchored controls go haywire because their positions are updated from the base form, but the form itself doesn't change.
Any ideas how to resolve (or work around) this?
Upvotes: 4
Views: 2487
Reputation: 942368
This will happen when you have the derived form opened in the designer. Which remembers the size it had. If you then modify the base form and rebuild then the designer will notice the derived form is no longer the same size as the base form and will record the size. You'll now have a permanent mismatch.
You avoid it by making sure the derived form isn't opened when you edit the base form. And that the base form is recompiled before you open the derived form. But, accidents are definitely going to happen, best to not rely on it. And in the greater scheme, the size should be left up to the user anyway.
You can fix it by right-clicking the derived form's Size property in the Properties window and clicking Reset
.
Upvotes: 6