PropertyGrid DefaultValues

The propertygrid shows entries in bold when they are not the default value. For the most part, I don't have any default values for my properties, so they all appear bold. This is very distracting. The idea of showing properties in bold when not default values is not really applicable for my use of the propertygird. Is there any way I can stop the values from ever appearing bold

Answer this question

PropertyGrid DefaultValues

  • Lonnie Barnett

    Thanks for the responses. This is great to know.

  • Saravanakumars38

    Hi,

    Please try looking at this link. Hope this should help you.
    http://msdn2.microsoft.com/en-us/library/aa302326.aspx

    Thank you,
    Bhanu.



  • ACHawk

    Nyet.
  • R.Tutus

    Hi,

    I looked into the PropertyGrid code and actually it seems there is only one solution. The DefaultValueAttribute is linked to the Serialization mechanism that the Visual Studio designer uses to fill the InitalizeComponent method. I don't know if this is an option for you but the only thing that I see is to disable this mechanism for each of your properties. The following code does the trick for one property:

    public class TargetClass
    {
    bool _myBool = false;

    private bool ShouldSerializeBoolean()
    {
    return false;
    }

    public bool Boolean
    {
    set { _myBool = value; }
    get { return _myBool; }
    }
    }

    You will notice the ShouldSerializeX method where x is the name of your property. For a formal explanation, look at this page at MSDN.
    Hope this helps.

    Best regards,

    Nicolas Cadilhac
    Smart PropertyGrid.Net @ VisualHint
    Microsoft PropertyGrid Resource List
    Free PropertyGrid for MFC

  • Dylan Morley

    Did you find an answer to this problem I am wondering the same thing.

  • pedestrian

    well, if you have the possibility to alter the TypeConverter classes when they exist or to create a reusable one, yes this is a good solution also.

    Best regards,

    Nicolas Cadilhac
    Smart PropertyGrid.Net @ VisualHint
    Microsoft PropertyGrid Resource List
    Free PropertyGrid for MFC

  • Gregor Jovan

    Thanks. In fact I can do this very easily for all properties by susbtituting a class's propertydescriptors with custom ones which override the ShouldSerializeValue function and return False on every occasion. The subsitution is made in the GetProperties function of the typeconverter for the class.

  • NET PR

    I'm aware of that article. It doesn't help me with this issue at all.

  • PropertyGrid DefaultValues