Click here to Skip to main content
12,818,489 members (34,618 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 17 May 2003


, 22 May 2003
Rate this:
Please Sign up or sign in to vote.
Property-Grid layout control


In many applications I use user interface controls, which provide property management functionality, similar to PropertyTab. The problem is that PropertyTab is not very useful, if properties are complex enough, custom controls required or additional activities needed. So I need an easy way to layout controls into one grid.


GridPanel implements custom layout - it places contained controls into one grid. One column of the grid contains labels (names of appropriate controls), another column contains controls. Above is an example of the grid with three controls. All controls can be accessed through the Controls property and they appear in the grid in the same order as in the Controls list. The grid labels are drawn in the OnPaint() handler - they are not stored as Label instances.

Using the code

GridPanel layouts contained controls, which can be accessed through the Controls property. Developer needs to set the Name property for each control. Each contained control preserves its height and width (except the case, then the Anchor property is set to left and right). Below is code snippet for the example, captured in the picture.

TextBox stext = new TextBox();
stext.Name = "Simple text";

TextBox mtext = new TextBox();
mtext.Name = "Complex text";
mtext.Multiline = true;
mtext.Anchor = AnchorStyles.Left|AnchorStyles.Right;
mtext.Height = stext.Height * 5;
mtext.ScrollBars = ScrollBars.Vertical;

ComboBox combo = new ComboBox();
combo.Name = "Drop down";
combo.DropDownStyle = ComboBoxStyle.DropDown;

GridPanel gp = new GridPanel(stext, mtext, combo);


  • 23 May 2003 - updated download


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Gytis Jakutonis
Lithuania Lithuania
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 23 May 2003
Article Copyright 2003 by Gytis Jakutonis
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid