469,946 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

inherited properties in userControl

Joe
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
Nov 17 '05 #1
2 2089
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:42**********************************@microsof t.com...
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

Nov 17 '05 #2
Joe
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:
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:42**********************************@microsof t.com...
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


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by adbarnet | last post: by
1 post views Thread by Juan Pedro Gonzalez | last post: by
3 posts views Thread by Wayne Brantley | last post: by
2 posts views Thread by Steven Nagy | last post: by
1 post views Thread by ben m | last post: by
5 posts views Thread by Martin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.