Home All Groups Group Topic Archive Search About

Problem with IDE when overriding Text property

Author
28 Feb 2006 4:03 PM
Jason Barnett
I noticed when overriding the Text property of the
System.Windows.Forms.UserControl that the Form.Designer file does not
reflect changes made via the property browser.  In other words, when you
override the Text property and then try to change it's value at design-time,
the value is not serialized and therefore not available at run-time.

This problem does not appear to be language specific; I've reproduced it in
C# and in VB.  Here are examples of what I've written:

In VB:
    <System.ComponentModel.Browsable(True)> _
    Public Overrides Property Text() As String
        Get
            Return lblTitle.Text
        End Get
        Set(ByVal value As String)
            lblTitle.Text = value
        End Set
    End Property


In C#:
        [System.ComponentModel.Browsable(true)]
        public override string Text
        {
            get { return lblTitle.Text; }
            set { lblTitle.Text = value; }
        }


Can anyone explain to me what is happening and how I might correct the
problem?

Author
28 Feb 2006 9:57 PM
Tim Wilson
You'll need to add some more attributes. See the example at the link below.
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/e3089235cb94cfe5?hl=en

--
Tim Wilson
..NET Compact Framework MVP

Show quote
"Jason Barnett" <j**@byrnesoftware.com> wrote in message
news:eqGfVCIPGHA.1040@TK2MSFTNGP12.phx.gbl...
> I noticed when overriding the Text property of the
> System.Windows.Forms.UserControl that the Form.Designer file does not
> reflect changes made via the property browser.  In other words, when you
> override the Text property and then try to change it's value at
design-time,
> the value is not serialized and therefore not available at run-time.
>
> This problem does not appear to be language specific; I've reproduced it
in
> C# and in VB.  Here are examples of what I've written:
>
> In VB:
>     <System.ComponentModel.Browsable(True)> _
>     Public Overrides Property Text() As String
>         Get
>             Return lblTitle.Text
>         End Get
>         Set(ByVal value As String)
>             lblTitle.Text = value
>         End Set
>     End Property
>
>
> In C#:
>         [System.ComponentModel.Browsable(true)]
>         public override string Text
>         {
>             get { return lblTitle.Text; }
>             set { lblTitle.Text = value; }
>         }
>
>
> Can anyone explain to me what is happening and how I might correct the
> problem?
>
>
Author
1 Mar 2006 7:56 PM
Jason Barnett
Thanks!  That really helps.


Show quote
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:OFBAVHLPGHA.2604@TK2MSFTNGP09.phx.gbl...
> You'll need to add some more attributes. See the example at the link
> below.
> http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/e3089235cb94cfe5?hl=en
>
> --
> Tim Wilson
> .NET Compact Framework MVP
>
> "Jason Barnett" <j**@byrnesoftware.com> wrote in message
> news:eqGfVCIPGHA.1040@TK2MSFTNGP12.phx.gbl...
>> I noticed when overriding the Text property of the
>> System.Windows.Forms.UserControl that the Form.Designer file does not
>> reflect changes made via the property browser.  In other words, when you
>> override the Text property and then try to change it's value at
> design-time,
>> the value is not serialized and therefore not available at run-time.
>>
>> This problem does not appear to be language specific; I've reproduced it
> in
>> C# and in VB.  Here are examples of what I've written:
>>
>> In VB:
>>     <System.ComponentModel.Browsable(True)> _
>>     Public Overrides Property Text() As String
>>         Get
>>             Return lblTitle.Text
>>         End Get
>>         Set(ByVal value As String)
>>             lblTitle.Text = value
>>         End Set
>>     End Property
>>
>>
>> In C#:
>>         [System.ComponentModel.Browsable(true)]
>>         public override string Text
>>         {
>>             get { return lblTitle.Text; }
>>             set { lblTitle.Text = value; }
>>         }
>>
>>
>> Can anyone explain to me what is happening and how I might correct the
>> problem?
>>
>>
>
>

AddThis Social Bookmark Button