7

Winforms has a control titled PropertyGrid. A display element of the PropertyGrid is a description area. By default it displays the name of the selected property. Using attributes, a programmer can have it display other text. I would like to remove it completely. It is taking up too much space and I don't need to have it display anything. I do not see any properties in the object model to remove it. Please post a solution for removing it.

Below is a screen shot of what I'm talking about. I would like to remove the area in red such that "PercentComplete" is at the bottom of the frame.

enter image description here

sapbucket
  • 6,795
  • 15
  • 57
  • 94

2 Answers2

18

Try setting the PropertyGrid's HelpVisible property to false.

vesan
  • 3,289
  • 22
  • 35
  • thank you, that did the trick. Anyone stuck on this problem use vesan's solution. You can use my solution (that uses reflection) if you want to change the height of the help window. – sapbucket Apr 27 '15 at 20:02
1

Add the following to your code:

private static void ChangeDescriptionHeight(PropertyGrid grid, int height)
{
    if (grid == null) throw new ArgumentNullException("grid");

    foreach (Control control in grid.Controls)
    {
        if (control.GetType().Name == "DocComment")
        {
            var fieldInfo = control.GetType().BaseType.GetField("userSized",
                                                                BindingFlags.Instance |
                                                                BindingFlags.NonPublic);
            fieldInfo.SetValue(control, true);
            control.Height = height;
            return;
        }
    }
}

And call it like this:

    var progressTimerProperties = new ProgressTimerProperties();
    propertyGridProgressTimer.SelectedObject = progressTimerProperties;

    ChangeDescriptionHeight(propertyGridProgressTimer, 0);

Notice that '0'? It sets the height of the description area to 0, effectively removing it. If you want you can go the opposite direction and make it bigger to accommodate more text.

sapbucket
  • 6,795
  • 15
  • 57
  • 94