LunchMarble
LunchMarble

Reputation: 5141

How do I make a property grid show certain values as readonly? C# .NET

There are properties that I want to not be editable via the property grid, but I still want them to be visible, even expandable.

How do I do this?

Upvotes: 2

Views: 535

Answers (1)

Haris Hasan
Haris Hasan

Reputation: 30097

you can use [ReadOnly(true)] attribute on properties which you want to make read only like this

[ReadOnly(true)]
public int ReadOnlyProperty
{
    get
    {
        return _ReadOnlyProperty;
    }
    set
    {
        _ReadOnlyProperty = value;
    }
}

Upvotes: 3

Related Questions