
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
>> > How are you applying attributes at runtime? As far as I'm aware,
>> > whether or not an attribute is applied to something is a compile-time
[quoted text clipped - 13 lines]
>
> Ah, I see - not like the normal way of applying attributes at all.
Yes, and I think the only time you typically have to resort to this is when
you need to get granular control over a "PropertyGrid" at runtime (there is
no other way AFAIK and the techniques are documented by both MSFT and others
of course). Figuring out all the details is a huge pain however (and it
takes an inordinate amount of code to implement ths simplest change). Is it
just me or are the .NET docs in general very weak?
> If your property *starts off* read-only, is it greyed out in the
> property grid? I wonder whether it's not noticing the change.
If I simply apply the read-only attribute to my customized "Size" property
then it grays it out but not its sub-properties ("Width" and "Height"). You
would think that it would but then again, my "Size" property is actually a
member of a larger object which I'm customizing the properties for (using
"PropertyDescriptor" objects). I see no reason why the read-only attribute
shouldn't be propagated to children however (without manual intervention
since again, it takes a lot of code to do this).
Jon Skeet [C# MVP] - 19 Feb 2007 19:01 GMT
> > If your property *starts off* read-only, is it greyed out in the
> > property grid? I wonder whether it's not noticing the change.
[quoted text clipped - 6 lines]
> shouldn't be propagated to children however (without manual intervention
> since again, it takes a lot of code to do this).
Is your Size type definitely a struct and not a class? I wonder if that
would make a difference - because strictly speaking, you could change
the contents of a reference type object without changing which object
was being referred to.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
John Allen - 20 Feb 2007 13:01 GMT
> Is your Size type definitely a struct and not a class? I wonder if that
> would make a difference - because strictly speaking, you could change
> the contents of a reference type object without changing which object
> was being referred to.
Yes, it is a struct. I'm still experimenting but will likely toss in the
towel and manually code things if I can't resolve it soon. Thanks again for
your help.
Jon Skeet [C# MVP] - 20 Feb 2007 13:43 GMT
> > Is your Size type definitely a struct and not a class? I wonder if that
> > would make a difference - because strictly speaking, you could change
[quoted text clipped - 4 lines]
> towel and manually code things if I can't resolve it soon. Thanks again for
> your help.
No problem (not that my help has been anything!) - but it does sound
interesting.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too