Click here to Skip to main content
Click here to Skip to main content

Change the height of a PropertyGrid's description area

, 28 Jul 2008
Rate this:
Please Sign up or sign in to vote.
How to change the height of a PropertyGrid's description area.


I recently created a tool that used a PropertyGrid. The property descriptions tended to be very long, and would not fit in the control's description area. I decided to change the description height at runtime, since I couldn't figure out how to do it at design time. Since I had no clue how to proceed (my first C# project and my first time using Visual Studio 7.1), I searched the web for existing solutions. I failed to find any C# solution on the Web, but I did find a VB article on Matthew Cosier’s blog, and adapted that code to my purposes.

Using the code

Simply insert the function below into your code and call it:

Private bool ResizeDescriptionArea(ref PropertyGrid grid, int nNumLines)
    System.Reflection.PropertyInfo pi = grid.GetType().GetProperty("Controls");
    Control.ControlCollection cc = (ControlCollection)pi.GetValue(grid, null);

    foreach(Control c in cc)
       Type ct = c.GetType();
       string sName = ct.Name;
       if(sName == "DocComment")
           pi = ct.GetProperty("Lines");
           pi.SetValue(c, nNumLines, null);

           System.Reflection.FieldInfo fi = ct.BaseType.GetField("userSized",
           fi.SetValue(c, true);

    return true;
  catch(Exception error)
        MessageBox.Show(error.Message, "ResizeDescriptionArea()");
     return false;

I call it like this:

private void Form1_load(object sender, System.EventArgs e)
    ResizeDescriptionArea(ref grid1, 6);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Geno Carman

United States United States
No Biography provided

Comments and Discussions

QuestionMaximized Form PinmemberScott 9710-Apr-12 10:49 
AnswerRe: Maximized Form PinmemberMember 15069666-Mar-14 12:19 
QuestionOK, but can you GET the height? PinmemberGraham Downs23-Feb-10 21:20 
AnswerRe: OK, but can you GET the height? PinmemberGeno Carman25-Feb-10 4:51 
GeneralRe: OK, but can you GET the height? PinmemberGraham Downs25-Feb-10 20:16 
GeneralRe: OK, but can you GET the height? PinmemberGeno Carman26-Feb-10 13:17 
GeneralRe: OK, but can you GET the height? PinmemberGraham Downs28-Feb-10 19:27 
GeneralThere is an error in the sample code PinmemberMember 151940420-Jan-10 3:44 
GeneralRe: There is an error in the sample code PinmemberGeno Carman25-Feb-10 4:56 
GeneralGet"ControlCollection"Fail Pinmemberelvis_pan22-Nov-08 18:09 
AnswerRe: Get"ControlCollection"Fail PinmemberGeno Carman23-Nov-08 5:56 
GeneralRe: Get"ControlCollection"Fail Pinmemberelvis_pan23-Nov-08 17:22 
GeneralRe: Get"ControlCollection"Fail PinmemberGeno Carman23-Nov-08 17:36 
GeneralRe: Get"ControlCollection"Fail Pinmemberelvis_pan23-Nov-08 20:23 
GeneralRe: Get"ControlCollection"Fail PinmemberGeno Carman24-Nov-08 14:58 
GeneralRe: Get"ControlCollection"Fail Pinmemberelvis_pan25-Nov-08 19:54 
GeneralRe: Get"ControlCollection"Fail Pinmemberjulian_perrott17-Mar-09 7:00 
Generalhi PinmemberMember 43421426-Aug-08 15:42 
GeneralRe: hi PinmemberGeno Carman6-Aug-08 18:54 
GeneralRe: hi PinmemberMember 434214211-Aug-08 15:03 
GeneralRe: hi PinmemberGeno Carman12-Aug-08 15:29 
GeneralRe: hi Pinmemberjmt9n29-Aug-08 5:14 
GeneralRe: hi PinmemberGeno Carman29-Aug-08 9:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 28 Jul 2008
Article Copyright 2008 by Geno Carman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid