tags:

views:

52

answers:

0

i have one class contact in "Contact.DLL" which has 10 properties , properties has attributes (like IsDisplayed),

now in different assembly"custom grid" , i am creating an form , where we query each attribute of class and display them in form.

now i have to hide some attributes based on "isneeded" property of contact object, if isneeded is true , it should display all property, and if not then not displayed.

bt i dont want to make any check in "custom grid" assembly, because this assembly is already referenced in contact.dll assembly

i tried to use following code but not able to achieved succesfully it is notdisplaying this property for everyobject

PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this)["IsNeeded"];

if (descriptor != null)
{
    IsDisplayPropertyAttribute attrib = (IsDisplayPropertyAttribute)
        descriptor.Attributes[typeof(IsDisplayPropertyAttribute)];

    if (attrib != null)
    {
        attrib.IsDisplayProperty = false;                        
    }
}