How to resize description area in PropertyGrid
Submitted by Tomasz Paprocki on 26 March, 2011 - 23:30
From this article you can learn how to resize description area in PropertyGrid. Example shows use of reflection in order to dig to private members of PropertyGrid - not accessible in normal way.
Implementation is available both in C# and VB.Net languages. Use buttons below to switch language visibility.
Implementation
System.Reflection namespace needs to be put in usings.
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") { FieldInfo fieldInfo = control.GetType().BaseType.GetField("userSized", BindingFlags.Instance | BindingFlags.NonPublic); fieldInfo.SetValue(control, true); control.Height = height; return; } }
Private Shared Sub ChangeDescriptionHeight(grid As PropertyGrid, height As Integer) If grid Is Nothing Then Throw New ArgumentNullException("grid") End If For Each control As Control In grid.Controls If control.[GetType]().Name = "DocComment" Then Dim fieldInfo As FieldInfo = control.[GetType]().BaseType.GetField("userSized", BindingFlags.Instance Or BindingFlags.NonPublic) fieldInfo.SetValue(control, True) control.Height = height Return End If Next End Sub
Comments
This Property Grid is able to
Kettic Property Grid is able to display the properties of any object in a user-friendly way and allows the end users of your applications edit the properties of the object.
Post new comment