propertydescriptor

Read-only PropertyGrid

Hi, I need to show an object in PropertyGrid with the following requirements: the object and its sub object must be read-only, able to activate PropertyGrid's CollectionEditors. I found a sample that's closely match to what I need but there's an unexpected behaviour I couldn't figure out. I have more than one PropertyGrids each for dif...

How to get all properties of an object and its sub objects

Hi, I have a similar question to this one except I need to loop all the sub objects and change the property to read-only Please check my code below. This one loop only the main object. When I tried to loop its sub objects, I got an overflow. Thanks. Public Class ReadOnlyTypeDescriptor Inherits CustomTypeDescriptor Priva...

Get the default PropertyDescriptors for a type

I'm customizing how an object type is displayed in a PropertyGrid by implementing ICustomTypeDescriptor. I'm allowing the user to create their own custom properties that are stored in a single dictionary of keys and values. I'm able to create all the PropertyDescriptors for these values and view them in the property grid. However, I also...

Resetting properties from a property grid

I am using a PropertyGrid to show properties from my objects. However, I'm also allowing the user to create their own properties, and set values for these custom properties. Each object that can have these custom properties has a Dictionary collection, where the string is a unique key to identify the property, and Object is the value of ...

ReadOnlyAttribute vs PropertyDescriptor.IsReadOnly()

What is the difference between using a PropertyDescriptor that returns a value for the IsReadOnly() method, and one that is associated with a ReadOnlyAttribute? ...

TypeDescriptor.GetProperties(thisType) to return properties, which are write-only

Hi, I'm trying to get all properties from a type, but using TypeDescriptor.GetProperties(thisType) will only supply me with properties, that has both setter and a getter. I have write-only properties. Are there a way to retrieve a PropertyDescriptorCollection including those? /Asger ...

Custom property descriptor and flattening hierarchies

I have a custom property descriptor that I use to support flattening object hierarchies. To accomplish this I subclassed PropertyDescriptor and I store a linked list to the "next" (child) property that I want to retrieve the value for. This enables me to bind subproperties to a grid(export to excel, whatever) in a "flat" manner. eg. ...

Add a category attribute to a PropertyDescriptor

I have a set of custom PropertyDescriptor that I want to add categories too so they display in a more organized fashion in a PropertyGrid. I want each type of PropertyDescriptor to go into a specific Category. I've tried using TypeDescriptor.AddAttributes() to add attributes to an existing PropertyDescriptor, but the category attribute ...

How do I add PropertyDescriptors to a class rather then override them?

If I have a class that implements ICustomTypeDescriptor I can override the GetProperties() method to completely replace all the properties of the class with my custom PropertyDescriptors. But what if i want to keep the existing properties of the class and append additional properties to the class? Is there a way to return a set of cust...

How to set default PropertyDescriptor to a property?

Are there an attribute for setting default PropertyDescriptor for a property? I just want to add a attribute to a property and specify PropertyDescriptor. And then the instance of the PropertyDescriptor would have been created. I haven't found the attribute in .net framework. ...

python descriptors sharing values across classes

A python descriptor that I'm working with is sharing it's value across all instances of it's owner class. how can I make each instances descriptor contain it's own internal values? class Desc(object): def __init__(self, initval=None,name='val'): self.val = initval self.name = name def __get__(self,obj,objtype): ...

C# - How to determine whether a property is changed

Hi Guys, I need to know whether a public property (which has getter & setter) is changed. The property is in a simple class (no user control/component etc). Is there an elegant way to subscribe to some kind of event which notifies when property is changed? I tried to see what microsoft is doing in their Binding object (using reflector) a...

Dynamically change properties returned by ICustomTypeDescriptor.GetProperties to readonly

I have a class which implements ICustomTypeDescriptor, and is viewed and edited by the user in a PropertyGrid. My class also has a IsReadOnly property which determines if the user will be able to save their changes later. I don't want to allow the user to make changes if they will not be able to save. So if IsReadOnly is true I want to o...

How does the Control class, provide the ForeColor, BackColor and Font default values?

I know that component-model indicates whether a property has a default value or not, by means of ShouldSerializeValue method of PropertyDescriptor. The base windows-forms Control class, has some properties like ForeColor, BackColor and Font, that defaults to the same value of the parent, but I could not find any TypeDescriptor or Proper...

how should I implement ICustomTypeDescriptor or a TypeDescriptionProvider so I have a consistent binding source for Winforms and webcontrols

Hi there. I have a datasource that is hierachy of objects defined as public interface ILink { Program Program { get; set; } int Linkid { get; set; } string SID { get; set; } bool IsActive { get; set; } } and [Serializable()] public abstract class AbstractLink : ISerializable, ILink, IEquatable<ILink>, ICloneable { ...