Click here to Skip to main content
15,846,091 members
Articles / Programming Languages / C#

Making an overridden Text property visible in the Visual Studio designer for a UserControl

Rate me:
Please Sign up or sign in to vote.
5.00/5 (8 votes)
14 Jun 2012CPOL 25.2K   3   4
Having the property "Text" be available for almost everything in .NET that interacts with the user makes life very simple. But when you create a new UserControl, the Text property doesn't appear in the Properties pane.


When you derive a new control from UserControl, you can happily get and set the Text property from your code - Intellisense finds it, it is a string, it works exactly as you expect.

Except... it doesn't appear in the Properties pane for your control. So your derived control instances can't set individual Text values at design time. Annoying.


You can try creating a Text property:

public string Text { get; set; }

...but the compiler complains it already exists, and suggests you try "new" or "override".  You can try overriding the Text property:

public override string Text { get; set; }

...and it works fine. Except it doesn't show in the designer.

You can try creating a new Text property:

public new string Text { get; set; }

... and it works fine, too. Still can't see it in the designer though. You can try setting the EditorBrowserVisibility:

public override string Text { get; set; }

...but that doesn't work either.  

Showing the Text Property in the designer  

[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
public override string Text {get; set;} 

Annoying? Yes.

Obvious? No.

Fixed? Yes.


Original version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Wales Wales
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?

Comments and Discussions

QuestionThank you very much for this tip... Pin
SungHwan Park1-Dec-16 13:45
SungHwan Park1-Dec-16 13:45 
QuestionNice and concise Pin
SBendBuckeye16-Jun-15 4:18
SBendBuckeye16-Jun-15 4:18 
GeneralThanks Pin
Ashraf Sabry19-Jan-13 9:58
Ashraf Sabry19-Jan-13 9:58 
GeneralSimple but... Pin
db7uk14-Jun-12 6:19
db7uk14-Jun-12 6:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.