Home > OS >  in a C# windows forms property grid, can you provide descriptions for the categories themselves?
in a C# windows forms property grid, can you provide descriptions for the categories themselves?

Time:11-16

In property grids, when you select an item it shows you the [description("")] helptext in the box at the bottom.

property selected property grid

When you are using the categorized view of the property grid, you also have the option to select the Category names themselves

category selected property grid

My Question is, is there a way to provide a description to the selected category that displays the same way description tags display for properties? E.g. when you select input you might see

Input
Items in this category are related to Input

Also, in case it's relevant, I'm just using a standard property grid populated by a class containing properties tagged with description and category

public class Foo
{
    [Category("Foo Category")]
    [Description("Foo Description help text")]
    public string fooProperty { get; set; } = "";
}

CodePudding user response:

The property grid is "open source".

This description text is set by this https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/PropertyGridInternal/PropertyGridView.cs,4496

this.ownerGrid.SetStatusBox(gridEntry.PropertyLabel,gridEntry.PropertyDescription);

And gridEntry for a category is handled by the CategoryGridEntry class https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/PropertyGridInternal/CategoryGridEntry.cs which derives from GridEntry class which defines PropertyDescription property here https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed/System/WinForms/PropertyGridInternal/GridEntry.cs,909 by this:

  public virtual string PropertyDescription {
            get {
                return null;
            }
        }

This property is not overridden in CategoryGridEntry, and all this is internal code, so, no, you can't have a description for categories grid entries.

  • Related