Connecting Tech Pros Worldwide Forums | Help | Site Map

inherited properties in userControl

Joe
Guest
 
Posts: n/a
#1: Nov 17 '05
OK, so i searched this forum, and it seems like my question has come close to
being answered a dozen times, but never fully...
I have a very simple control that inherits from UserControl. It has no
child controls, just properties and custom drawing. I would like one of
these properties to be 'Text'.
So i setup a private _Text field (base.Text not accessible) and public
String Text property. I have tried using both 'override' and 'new' keywords,
but the results appear to be the same, which is limited access to the Text
property when trying to use the control on a Designer form. The best I can
do is to get the property to show up in the IDE property window, but nothing
else. I can set the Text in the property window, but the Form Designer does
not generate the corresponding code to set the property, so when I run my
project, the Text i set has reverted back to the default text. I can
manually go into the designer code and put the line in myself, run the
project, and everything works as expected. If i do the same, but then go
back to the designer and change the Text in the property window, the code i
just inserted gets erased.
I'm assuming this an inheritance issue, since all my other non-inherited
properties exhibit the expected behavior. This seems like it should be an
easy answer, but it's got me frustrated. Is there another issue here, like
the fact that the text property comes from 3 levels of inheritance down? I
know I could probably avoid all this by just changing the property name, but
I'd like to stick with the commonality theme if at all possible.
Thanks in advance,
Joe

Tim Wilson
Guest
 
Posts: n/a
#2: Nov 17 '05

re: inherited properties in userControl


Try using a declaration as shown at the link below.
http://groups-beta.google.com/group/...cb94cfe5?hl=en

--
Tim Wilson
..Net Compact Framework MVP

"Joe" <joe.klecha-AT-digeratisolutions-DOT-net> wrote in message
news:42231F87-B635-4FB7-9C05-A3020CA93AEE@microsoft.com...[color=blue]
> OK, so i searched this forum, and it seems like my question has come close[/color]
to[color=blue]
> being answered a dozen times, but never fully...
> I have a very simple control that inherits from UserControl. It has no
> child controls, just properties and custom drawing. I would like one of
> these properties to be 'Text'.
> So i setup a private _Text field (base.Text not accessible) and public
> String Text property. I have tried using both 'override' and 'new'[/color]
keywords,[color=blue]
> but the results appear to be the same, which is limited access to the Text
> property when trying to use the control on a Designer form. The best I[/color]
can[color=blue]
> do is to get the property to show up in the IDE property window, but[/color]
nothing[color=blue]
> else. I can set the Text in the property window, but the Form Designer[/color]
does[color=blue]
> not generate the corresponding code to set the property, so when I run my
> project, the Text i set has reverted back to the default text. I can
> manually go into the designer code and put the line in myself, run the
> project, and everything works as expected. If i do the same, but then go
> back to the designer and change the Text in the property window, the code[/color]
i[color=blue]
> just inserted gets erased.
> I'm assuming this an inheritance issue, since all my other non-inherited
> properties exhibit the expected behavior. This seems like it should be an
> easy answer, but it's got me frustrated. Is there another issue here,[/color]
like[color=blue]
> the fact that the text property comes from 3 levels of inheritance down?[/color]
I[color=blue]
> know I could probably avoid all this by just changing the property name,[/color]
but[color=blue]
> I'd like to stick with the commonality theme if at all possible.
> Thanks in advance,
> Joe[/color]


Joe
Guest
 
Posts: n/a
#3: Nov 17 '05

re: inherited properties in userControl


I had previously tried setting Browsable and EditorBrowsable..
DesignerSerializationVisibility and Bindable must have did the trick, cause
it works now. Thanks Tom

"Tim Wilson" wrote:
[color=blue]
> Try using a declaration as shown at the link below.
> http://groups-beta.google.com/group/...cb94cfe5?hl=en
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "Joe" <joe.klecha-AT-digeratisolutions-DOT-net> wrote in message
> news:42231F87-B635-4FB7-9C05-A3020CA93AEE@microsoft.com...[color=green]
> > OK, so i searched this forum, and it seems like my question has come close[/color]
> to[color=green]
> > being answered a dozen times, but never fully...
> > I have a very simple control that inherits from UserControl. It has no
> > child controls, just properties and custom drawing. I would like one of
> > these properties to be 'Text'.
> > So i setup a private _Text field (base.Text not accessible) and public
> > String Text property. I have tried using both 'override' and 'new'[/color]
> keywords,[color=green]
> > but the results appear to be the same, which is limited access to the Text
> > property when trying to use the control on a Designer form. The best I[/color]
> can[color=green]
> > do is to get the property to show up in the IDE property window, but[/color]
> nothing[color=green]
> > else. I can set the Text in the property window, but the Form Designer[/color]
> does[color=green]
> > not generate the corresponding code to set the property, so when I run my
> > project, the Text i set has reverted back to the default text. I can
> > manually go into the designer code and put the line in myself, run the
> > project, and everything works as expected. If i do the same, but then go
> > back to the designer and change the Text in the property window, the code[/color]
> i[color=green]
> > just inserted gets erased.
> > I'm assuming this an inheritance issue, since all my other non-inherited
> > properties exhibit the expected behavior. This seems like it should be an
> > easy answer, but it's got me frustrated. Is there another issue here,[/color]
> like[color=green]
> > the fact that the text property comes from 3 levels of inheritance down?[/color]
> I[color=green]
> > know I could probably avoid all this by just changing the property name,[/color]
> but[color=green]
> > I'd like to stick with the commonality theme if at all possible.
> > Thanks in advance,
> > Joe[/color]
>
>
>[/color]
Closed Thread