|
-
Sep 28th, 2009, 12:29 PM
#1
Removing properties from a control that is already used
Hey,
I first noticed this problem using C#, but I thought at that time it was something that did not happen in VB, so I posted a similar question in the C# forums. I never saw it happen before, but it seems it does happen in VB too, so I decided to post the question again here in the hope that VB at least has something that helps me...
The problem is that I have many (around 30) instances of a custom control on a Form. The custom control is just a class inheriting from Panel with some new properties. I decided to create two BackgroundColor properties (1 and 2) to allow for gradient backgrounds. I'm not sure if this matters, but I simply left the second BackgroundColor property empty (never initialized it), because I was not using it yet.
After placing around 30 instances no my form, all in different levels of nesting in different FlowLayoutPanels (took me an hour at least to get everything right), I tested it out and decided it looked ok, and it didn't need a gradient background color after all.
So, I went in the custom control code and simply deleted the second BackgroundColor property.
The result was 30 errors in the form's Designer.vb file. It seems each control was still trying to set the property (to Color.Empty), but obviously could not find it.
I could no longer access the form's design view, except if I click the 'ignore' button and lose all the controls.
Is there no way I can 'safely' remove a property from a control that is already on a form, so that the designer file updates itself accordingly and no longer tries to set the removed property?
It seems foolish that I have to remove the 30 errors (actually 120, because I still need to remove 3 more properties) manually from the designer file, when I know the editor is perfectly capable of finding all references to some name and for example renaming them (the context menu Rename function), so why not delete them?
I am sure I'm simply missing something basic here that I somehow never learned and never needed before in 2 or 3 years of using VB.NET... If not, do I really have to remove 120 lines manually, each hidden deep in the designer code in different lines?!
I know I could simply remove all controls and re-add them, that would get rid of the errors, but it will take me forever to set them up again correctly, including the events etc... I don't want to do that really. I just want to know how to do it correctly.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|