2

I know it's stupid but visual studio (2010) doesn't gray out my properties tagged with ReadOnlyAttribute, I can't edit their values (if I try to do it, simply return to the previous value), but they aren't grayed out, I think it's really boring this when using the editor

Is there an option or an attribute that I'm forgetting?

Thanks for any help

Example 1:

    /// <summary>
    /// Inform if the LcdDisplay has been already initiated
    /// </summary>
    [Description("Inform if the LcdDisplay has been already initiated")]
    [DefaultValue(false)]
    [ReadOnly(true)]
    public bool Initialized { get; private set; }

Initialized is not grayed out

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147

2 Answers2

0

This behavior is by design.

To make the property grayed out, remove the setter. (or make it private)

If you only want it to be readonly at designtime, you can make a separate writable property and add [Browsable(false)] to hide it from the property grid.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

The only way to have this behaviour is not to have a setter, maybe because the designer see the private field as something that he can access to so it doesn't gray out it.

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147