Mike Hofer
Mike Hofer

Reputation: 17022

.NET PropertyGrid Collection Editor and List<T>

I'm using the PropertyGrid control in a WinForms application. The window itself binds to a class that contains a list of objects. While I'd prefer it if the grid just expanded and let the user modify the items like a tree-view, I'll settle for the collection editor if it will stop listing the members as "Roswell.Windows.Command.Model" (the fully-resolved class name).

I have appplied the DisplayName attribute to both the containing property and the class itself, but the collection editor window itself seems to ignore it.

(FWIW, this is .NET 3.5 in VStudio 2008.)

Any suggestions? I've googled (and SO'd!!) until I'm blue in the face.

Upvotes: 1

Views: 1961

Answers (2)

leppie
leppie

Reputation: 117250

You can override ToString()

  • or -

Implement a TypeConvertor for your class or property.

Upvotes: 2

Fredrik Mörk
Fredrik Mörk

Reputation: 158309

You can override the ToString method to provide a nicer value (C# example)

class MyClass
{
    public string SomeValue { get; set; }

    public override string ToString()
    {
        return string.Format("SomeValue={0}", this.SomeValue);
    }
}

Upvotes: 2

Related Questions