Click here to Skip to main content
Licence 
First Posted 17 May 2003
Views 64,217
Bookmarked 18 times

GridPanel

By | 22 May 2003 | Article
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

About the Author

Gytis Jakutonis



Lithuania Lithuania

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 23 May 2003
Article Copyright 2003 by Gytis Jakutonis
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid