Hi,
I'm trying to add an attribute to a colour property by using the create property method. The attribute i'm trying to add is the browsableAttribute but i am getting an error saying the entity key already exists.
the code i'm using is below:
protected
PropertyDescriptorCollection GetPropertiesInternal(Attribute[] attributes)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this, attributes, true);
PropertyDescriptor[] propertiesArray = new PropertyDescriptor[properties.Count];
for (int i = 0; i < properties.Count; i++)
{
if (properties
.Name == "BackColour")
{
bool makeReadOnly = !m_PromptDefinition is ReadOnlyDefinition
propertiesArray
= TypeDescriptor.CreateProperty(GetType(), properties
, new Attribute[] { new BrowsableAttribute(makeReadOnly) });
}
else if (properties
.Name == "ForeColour")
{
bool makeReadOnly = !m_PromptDefinition is ReadOnlyDefinition
propertiesArray
= TypeDescriptor.CreateProperty(GetType(), properties
, new Attribute[] { new BrowsableAttribute(makeReadOnly) });
}
else
{
propertiesArray
= properties
;
}
}
properties =
new PropertyDescriptorCollection(propertiesArray);
return properties;
}
I have changed this to be a readOnlyAttributeand it works fine. I thought that maybe it was because the colour property has a default browsableAttribute and trying to add another one caused this error but the property also has a default readOnlyAttribute. I'm really confused.
Can anybody offer some advise?
Thanks