Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding unwanted properties in custom controls

Tags:

Is this the way to hide properties in derived controls?

public class NewButton : Button

...

[Browsable ( false )] public new ContentAlignment TextAlign { get; set; } 

Also this hides the property in the Properties window in the designer but how can I also hide the property in code?

like image 910
Joan Venge Avatar asked Oct 06 '09 22:10

Joan Venge


1 Answers

From code, the closest you can do it to hide it, and perhaps make it a pain to call directly - note that even when hidden it is callable, and none of this will work past a cast:

// about the closest you can do, but not really an answer [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("just cast me to avoid all this hiding...", true)] public new ContentAlignment TextAlign { get; set; } 

Personally, I wouldn't bother. It isn't robust (just cast).

like image 174
Marc Gravell Avatar answered Nov 01 '22 17:11

Marc Gravell