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

GridPanel

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

Introduction

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.

Background

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);

History

  • 23 May 2003 - updated download

License

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

Share

About the Author

Gytis Jakutonis

Lithuania Lithuania
No Biography provided

Comments and Discussions

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