bpayne111 Posted December 23, 2003 Posted December 23, 2003 #region Properties [Category("Appearance"),Description("The text to display")] override public string Text { get{return _text;} set{ _text= value;} } #endregion i have declared a property like so in a user control. My goal is to make the text property appear in the form designer. I've had this work before in vb but it's not showing up like i'm used to in c#. Is there a step involved i'm missing? thanks brandon Quote i'm not lazy i'm just resting before i get tired.
bpayne111 Posted December 24, 2003 Author Posted December 24, 2003 too add to the prior statement... i used new in my declaration because the text property is alraedy included in the userControl class but not displayed in the form designer. That prompted me to shadow the property and add a category and description? i'm suprised no one has responded to this it seems like a rather easy issue. after all i did this all the time in vb but not in c# things don't seem to be the same. heeeeeeeeeeeeeeeeeeeeelp thanks brandon Quote i'm not lazy i'm just resting before i get tired.
AlexCode Posted December 24, 2003 Posted December 24, 2003 I really don't know what's wrong with your code ... sorry... I'nm a VB programmer and I should say to you that you never should have left VB :p But I'm really posting this because reading your post reminded me yhat I never got to be able to add the description of a property of a control on that yellow tag of the intelicensse... Do you happend to know how this is donne? ... in VB ofcourse! :D Alex :D Quote Software bugs are impossible to detect by anybody except the end user.
bpayne111 Posted December 24, 2003 Author Posted December 24, 2003 yes it's very simple just use the same code i posted above only 'vb style' <Category("Appearance"),Description("The text to display")>Public Property Anything as String i'm pretty sure that will work it worked for my control that i created in vb. OHHH WAIT do you mean while you are coding or in the form designer? that code will add it to the form designer. VB DOES NOT allow you to add descriptions of your own classes to the intellisense. it looks like C# does have it's advantages C# uses an xml tag to do this before the declaration. but i do remember reading in my oop book that vb won't let you do it. with my experience so far C# is more confusing than vb but it seems to be more flexible to me. sorry about your property descriptions... maybe you should make the switch like me. after all it seems to me more employeers like C better than vb anyway so i figured it'll look better on a resume. especially if i get a job and they aren't in .NET yet... it'll be easy for me to learn C++ then if i have to (like i want to!!!!!) thanks later brandon ps other properties of my control did get added to the designer but the text property would not work... i simply changed the name of it to DisplayText and it worked fine.... i'd rather use just Text but ohh well it's still in the Appearance category so people will figure it out. Quote i'm not lazy i'm just resting before i get tired.
TpB Posted February 21, 2004 Posted February 21, 2004 How to do it... UserControl inherits from the Control class, in the process it override the Text property. The best fix is to step back one class. Set up your control class this way... public class ExtremeButton : System.Windows.Forms.Control { /* Then take over the text property this way... */ [browsable(true)] public override string Text { get{return base.Text;} set{base.Text = value; this.Refresh();} } } Quote
bpayne111 Posted February 22, 2004 Author Posted February 22, 2004 wow this was an old post but i'll check it out thanks... brandon Quote i'm not lazy i'm just resting before i get tired.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.