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 (propertiesIdea.Name == "BackColour")

{

bool makeReadOnly = !m_PromptDefinition is ReadOnlyDefinition

propertiesArrayIdea = TypeDescriptor.CreateProperty(GetType(), propertiesIdea, new Attribute[] { new BrowsableAttribute(makeReadOnly) });

}

else if (propertiesIdea.Name == "ForeColour")

{

bool makeReadOnly = !m_PromptDefinition is ReadOnlyDefinition

propertiesArrayIdea = TypeDescriptor.CreateProperty(GetType(), propertiesIdea, new Attribute[] { new BrowsableAttribute(makeReadOnly) });

}

else

{

propertiesArrayIdea = propertiesIdea;

}

}

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