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