Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Inheritance - Property Getter/Setter doesn't seem to work 1

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
0
0
GB
I have a 2 forms - parent and child.

The parent has a property related to a label control, like so:

Code:
[Category("ToggleFooLabel")]
[Description("Set whether label is visible or not")]
public bool ToggleFooLabel
    {
        get { return lblFoo.Visible; }
        set { lblFoo.Visible = value; }
    }

Now - this is "supposed" to be a clean and safer way to handle your inherited controls, rather than using the Protected keyword route.
My child form now shows the ToggleFooLabel in the list of properties for that form and TRUE/FALSE dropdown - well cool! really nice so I set the FooLabel to be FALSE, I just dont want to see it in my child form but its ok to see on the parent. However on running the program the form shows the label on the child???!!!! Like it never even cared!!! Anyone know whats going on??
 
Stop hurting yourself. Visual inheritance doesn't work and MS know it, they left it out of the feature list after 2003.



Christiaan Baes
Belgium

My Blog
 
So what do you do if you have forms that share similar functionality ? Do you explicitly deactivate controls etc.
 
I use inheritance and good old fashioned manual labor. The designer gives up if you use inheritance so I give up on the designer. You shouldn't be figthing the designer to get things done. It's there to help us.


Christiaan Baes
Belgium

My Blog
 
This is rubbish - how can MS make such a big song and dance out of this functionality and even have it on the their certification exam!!! - and it does not work! Amazing!
 
Look up the feature lists of VS 2002/2003/2005 and 2008 you will see that visual inheritance just disapears from the list.

It doesn't work and they know it. And you get even more in trouble with collections like the menu. try inheriting from a form that has a menu with submenu's and add a submenu somewhere in the middle of other submenu's.

I know it is hard but there are worse things in life. I ussually forget about inheritance with forms apart form some basic things.

Let's not forget that they didn't make it with OO in mind.

Christiaan Baes
Belgium

My Blog
 
And count yourself lucky. I used some DI for some of my controls so I could inject the controller/observable. The only constructor needs a parameter So the designer even refuses to draw the form after that it needs an empty constructor to do it's thing. And don't do fancy things in the load event either because I have noticed that it executes that to.

So the designer get's a bit quirky when you get to fancy with your forms and/or controls. And you have to compromise.

Christiaan Baes
Belgium

My Blog
 
have you got a link to the feature lists - Im just curious?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top