Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

PropertyGrid and nested property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Dunaway - 27 Aug 2004 18:15 GMT
I have a custom control derived from button.  One property is an instance
of the following simple class, which is used to paint the button with
different colors:

Public Class Style
   Private _ColorStart As Color
   Private _ColorEnd As Color
   Private _ColorHighlight As Color

   Public Property ColorStart() As Color
       Get
           Return _ColorStart
       End Get
       Set(ByVal Value As Color)
           _ColorStart = Value
       End Set
   End Property

   Public Property ColorEnd() As Color
       Get
           Return _ColorEnd
       End Get
       Set(ByVal Value As Color)
           _ColorEnd = Value
       End Set
   End Property

   Public Property ColorHighlight() As Color
       Get
           Return _ColorHighlight
       End Get
       Set(ByVal Value As Color)
           _ColorHighlight = Value
       End Set
   End Property

End Class

The property is declared like this:

<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Property ClickedStyle() As Style
   Get
       Return _ClickedStyle
   End Get
   Set(ByVal Value As Style)
       _ClickedStyle = Value
   End Set
End Property
   

Note that I have applied the TypeConverter attribute so that in the
PropertyGrid, the property can be expanded to show the individual colors.
This seems to work ok.

The problem is that, when I change the individual colors, it does not seem
to affect the visual display of the button.  Not on the designer nor at
runtime.

For example, the defualt colors are red.  In the designer I can change the
color to blue and it seems to be changed, but on the form the color of the
button does not change, nor does it change at runtime.  At runtime, when I
inspect the property, it still has the default values.

It seems like the property is being changed in the PropertyGrid but the
button object is not reflecting the change.

Any clues?

Signature

Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Sijin Joseph - 29 Aug 2004 08:26 GMT
Are you using a custom designer for your control, i think you will need
to use one, in order to itercept the property value change and then
update the visual appearance of your control at design time.

Check out these articles

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/c
ustdsgnrdotnet.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/c
ustcodegen.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/u
singpropgrid.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/v
snetpropbrow.asp


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> I have a custom control derived from button.  One property is an instance
> of the following simple class, which is used to paint the button with
[quoted text clipped - 64 lines]
>
> Any clues?
Chris Dunaway - 01 Sep 2004 16:00 GMT
> Are you using a custom designer for your control, i think you will need

Thanks for the reply.  I resolved my problem by adding an event to the
class.  When a property is changed, I raise the event.  That works in the
designer as well and is simpler than implementing a custom designer for the
class.
Signature

Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.