ExpandableObjectConverter and Accessor

  • Thread starter Thread starter Pol Bawin
  • Start date Start date
P

Pol Bawin

Hi,

I have a objectA with a property that return an object B (accessor GET only)

I have defined an ExpandableObjectConverter on the type B and overrided
CanConvertTo, CanConvertFrom, ...
The problem is that can not edit the object B (the proerty in greyed) in the
propertyGrid (I can edit these properties but not the object directly
because, it doesn't have SET accessor)
In fact, when I edit this object, I woul like to change just the properties
without recreate this object.

It's a simple schema of my problem
Point 12, 0, 0 <- this line is greyed without a SET accessor
X 12
Y 0
Z 0

A solution exists without to define a SET accessor?
 
Hi Pol,

I think if you apply [TypeConverter(typeof(ExpandableObjectConverter))] to
this property, its child fields will can be seen, and can be modified.
So I think this can meet your need.
If you inherited the ExpandableObjectConverter and implemented ConvertTo,
ConverFrom,CanConvertFrom, CanConvertTo method, the object field will
display your customized string. Because your property is readonly(only has
get accessor), your object property fiedl will be gray. This is by design.
If you still want to change the object's value through the object
customized string not the child fields, I think you can do like this:
1. add a empty set accessor to this property.(This enables the property's
customized string to can be modified)
2. in ConvertFrom method, refer to ITypeDescriptorContext.Instance field,
it will return to you the control's reference, then you can change certain
field of control's this property.(but not create a property object)

This logic works well on my machine. Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Pol Bawin" <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Subject: ExpandableObjectConverter and Accessor
| Date: Wed, 29 Oct 2003 17:05:21 +0100
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Lines: 22
| Message-ID: <[email protected]>
| Organization: -= Belgacom Usenet Service =-
| NNTP-Posting-Host: 194.78.114.66
| X-Trace: 1067443526 reader3.news.skynet.be 16227 194.78.114.66:52148
| X-Complaints-To: (e-mail address removed)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!skynet.be!skynet.be!louie!tlk!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:195092
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi,
|
| I have a objectA with a property that return an object B (accessor GET
only)
|
| I have defined an ExpandableObjectConverter on the type B and overrided
| CanConvertTo, CanConvertFrom, ...
| The problem is that can not edit the object B (the proerty in greyed) in
the
| propertyGrid (I can edit these properties but not the object directly
| because, it doesn't have SET accessor)
| In fact, when I edit this object, I woul like to change just the
properties
| without recreate this object.
|
| It's a simple schema of my problem
| Point 12, 0, 0 <- this line is greyed without a SET accessor
| X 12
| Y 0
| Z 0
|
| A solution exists without to define a SET accessor?
|
|
|
|
 
Back
Top