How to remove a description area from a property grid?

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

Below is a screenshot of which I'm talking about. I would like to delete the area in red, so that "PercentComplete" is at the bottom of the frame.

enter image description here

+5
source share
2 answers

Try setting the PropertyGrid HelpVisible property to false .

+9
source

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 name it as follows:

  var progressTimerProperties = new ProgressTimerProperties(); propertyGridProgressTimer.SelectedObject = progressTimerProperties; ChangeDescriptionHeight(propertyGridProgressTimer, 0); 

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

+1
source

All Articles