.NETGURU
PropertyGrid and nested property
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.

Post a new message to this list...

Chris Dunaway
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?

--
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.
Reply to this message...
 
    
Sijin Joseph
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/custdsgnrdotnet.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp

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

Chris Dunaway wrote:
[Original message clipped]

Reply to this message...
 
    
Chris Dunaway
On Sun, 29 Aug 2004 12:56:23 +0530, Sijin Joseph wrote:

> 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.
--
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.
Reply to this message...
 
 
System.ComponentModel.ExpandableObjectConverter
System.ComponentModel.TypeConverter
System.Windows.Forms.PropertyGrid




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification