Click here to Skip to main content
13,087,566 members (95,360 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 28 Jul 2008

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

You may also be interested in...


Comments and Discussions

QuestionMaximized Form Pin
Scott 9710-Apr-12 10:49
memberScott 9710-Apr-12 10:49 
AnswerRe: Maximized Form Pin
Member 15069666-Mar-14 12:19
memberMember 15069666-Mar-14 12:19 
QuestionOK, but can you GET the height? Pin
Graham Downs23-Feb-10 21:20
memberGraham Downs23-Feb-10 21:20 
AnswerRe: OK, but can you GET the height? Pin
Geno Carman25-Feb-10 4:51
memberGeno Carman25-Feb-10 4:51 
GeneralRe: OK, but can you GET the height? Pin
Graham Downs25-Feb-10 20:16
memberGraham Downs25-Feb-10 20:16 
GeneralRe: OK, but can you GET the height? Pin
Geno Carman26-Feb-10 13:17
memberGeno Carman26-Feb-10 13:17 
GeneralRe: OK, but can you GET the height? Pin
Graham Downs28-Feb-10 19:27
memberGraham Downs28-Feb-10 19:27 
GeneralThere is an error in the sample code Pin
Member 151940420-Jan-10 3:44
memberMember 151940420-Jan-10 3:44 
GeneralRe: There is an error in the sample code Pin
Geno Carman25-Feb-10 4:56
memberGeno Carman25-Feb-10 4:56 
GeneralGet"ControlCollection"Fail Pin
elvis_pan22-Nov-08 18:09
memberelvis_pan22-Nov-08 18:09 
AnswerRe: Get"ControlCollection"Fail Pin
Geno Carman23-Nov-08 5:56
memberGeno Carman23-Nov-08 5:56 
GeneralRe: Get"ControlCollection"Fail Pin
elvis_pan23-Nov-08 17:22
memberelvis_pan23-Nov-08 17:22 
GeneralRe: Get"ControlCollection"Fail Pin
Geno Carman23-Nov-08 17:36
memberGeno Carman23-Nov-08 17:36 
GeneralRe: Get"ControlCollection"Fail Pin
elvis_pan23-Nov-08 20:23
memberelvis_pan23-Nov-08 20:23 
GeneralRe: Get"ControlCollection"Fail Pin
Geno Carman24-Nov-08 14:58
memberGeno Carman24-Nov-08 14:58 
GeneralRe: Get"ControlCollection"Fail Pin
elvis_pan25-Nov-08 19:54
memberelvis_pan25-Nov-08 19:54 
GeneralRe: Get"ControlCollection"Fail Pin
julian_perrott17-Mar-09 7:00
memberjulian_perrott17-Mar-09 7:00 
Generalhi Pin
Member 43421426-Aug-08 15:42
memberMember 43421426-Aug-08 15:42 
GeneralRe: hi Pin
Geno Carman6-Aug-08 18:54
memberGeno Carman6-Aug-08 18:54 
GeneralRe: hi Pin
Member 434214211-Aug-08 15:03
memberMember 434214211-Aug-08 15:03 
GeneralRe: hi Pin
Geno Carman12-Aug-08 15:29
memberGeno Carman12-Aug-08 15:29 
GeneralRe: hi Pin
jmt9n29-Aug-08 5:14
memberjmt9n29-Aug-08 5:14 
GeneralRe: hi Pin
Geno Carman29-Aug-08 9:34
memberGeno Carman29-Aug-08 9:34 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170813.1 | Last Updated 28 Jul 2008
Article Copyright 2008 by Geno Carman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid