I circumvented the problem by this system :
When the object must be locked , I pass at the SelectedObject (in the
PropertyGrid) an object ObjectLocked that has a reference to the object
otherwise I pass directly the object
[ReadOnly(true)
public class ObjectLocked
{
private readonly object _Reference;
public ObjectLocked(object o)
{
_Reference = o;
}
[TypeConverter(typeof(LockedObjectConverter))]
public object Object
{
get { return _Reference; }
}
}
internal class LockedObjectConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value, Type
destinationType)
{
return "This object is locked";
}
}
"Polo" <pb@rtech.be> a écrit dans le message de
news:3f**********************@news.skynet.be...
Hi All,
I would like to apply dynamically the ReadOnlyAttribute(True - False) on a
class to lock or not the edition of instances of it in the property grid
An other solution is welcome.
Syncerely
Polo