ExpandableObjectConverter and Accessor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pol Bawin

    ExpandableObjectConverter and Accessor

    Hi,

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

    I have defined an ExpandableObjec tConverter 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?



  • Jeffrey Tan[MSFT]

    #2
    RE: ExpandableObjec tConverter and Accessor


    Hi Pol,

    I think if you apply [TypeConverter(t ypeof(Expandabl eObjectConverte r))] 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 ExpandableObjec tConverter and implemented ConvertTo,
    ConverFrom,CanC onvertFrom, 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 ITypeDescriptor Context.Instanc e 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" <pb@rtech.be>
    | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    | Subject: ExpandableObjec tConverter 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: <3f9fe544$0$162 27$ba620e4c@rea der3.news.skyne t.be>
    | Organization: -= Belgacom Usenet Service =-
    | NNTP-Posting-Host: 194.78.114.66
    | X-Trace: 1067443526 reader3.news.sk ynet.be 16227 194.78.114.66:5 2148
    | X-Complaints-To: usenet-abuse@skynet.be
    | Path:
    cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
    e.de!skynet.be! skynet.be!louie !tlk!not-for-mail
    | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1950 92
    | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    |
    | Hi,
    |
    | I have a objectA with a property that return an object B (accessor GET
    only)
    |
    | I have defined an ExpandableObjec tConverter 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?
    |
    |
    |
    |

    Comment

    Working...