Questions & Answers

WinBooks Features

Using WinBooks layout in building form.

Mode - Represents the mode of the control that is used to calculate the size and the location of that control.

Namespace : Winbooks.Framework.Controls
Assembly : WbksFw

Modifier

Name

Description

Contiguous

The control will always be placed right after it s previous control.

Fixed

The width and height of the control will not be changed when it s container is resized.

HeightFixed

The height of control will not be changed event if it s container is resized.

HeightResizable

The height of the control will be changed to be equal with it s row s height when it s container is resized.

Over

The control s location will be the same with it s previous control.

Right

The control will be placed on the same row of the previous control and at the next column.

RightAlign

The control will be right align inside parent container

Under

The control will be palced at the begining of the next row.

WidthFixed

The width of the control will not be changed event if it s container is resized.

WidthResizable

The width of the control will be changed to be equal with it s column s width, and to reach the right border of it s container if the control is the last one of the row when it s container is resized.

XY

The location of the control won t be calculated automatically but manually set by user and won t be changed when it s container is resized.

Here are demos for each Mode

  • ContinuousMode ContinuousModeContinuousMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class ContinuousModeLayoutsForm : ZForm
        {
                                public ContinuousModeLayoutsForm()
            {
                                this.Text = "Continuous Mode";
                                this.YMargin = 10;
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public void CreateControls(IContainer parent)
            {
                                //Add a label in at new row of parent container
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Controls in row 1 are applied Mode value");
                lblInfo.Parent = parent;
                lblInfo.Multiline = true;
                                //Create a control group applying Mode.Right | Mode.Continuous on row 1
                                this.CreateGroupWithRow1AppliedModeRightAndContinuous(parent);
                                //Create a control group applying Mode.Right on row 1
                                this.CreateGroupWithRow1AppliedModeRight(parent);
                                //Summary:
                                //  Mode.Contiguous means that a created control is placed next to the last created control in a same row.
                                //  However, the container does not create a new column for the control.
            }
                                /// <summary>
                                /// Create a control group whose Row 1 applied Mode.Right
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateGroupWithRow1AppliedModeRight(IContainer parent)
            {
                                //Create a groupbox container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under | Mode.WidthFixed, //Control Mode
                                "ccControlContainer1", //Control Key
                                "Mode.Right" //Group box name
                                              );
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxContainer.ForeColor = Color.FromRGB(0, 128, 64);
                gbxContainer.BorderColor = Color.FromRGB(0, 128, 64);
                gbxContainer.Font = new Font("Tahoma", 8.5, FontStyle.Bold);
                
                                #region Row 1 of the container
                                //Add a textbox at row 1 - column 1 of gbxContainer container 
                                 ZTextBox tbxReference = new ZTextBox(Mode.Right | Mode.WidthFixed, new Source("tbxReference1"), 130);
                tbxReference.Parent = gbxContainer;
                                //Add an image button at row 1 - column 2 of gbxContainer container
                                 ZButton btnImage = new ZButton(Mode.Right, "btnImage2", "");
                btnImage.Parent = gbxContainer;
                btnImage.ImageIndex = ImageSixteenShadow.NoteYellow;
                                //Add an image button at row 1 - column 3 of gbxContainer container
                                 ZButton btnImage1 = new ZButton(Mode.Right, "btnImage22", "");
                btnImage1.Parent = gbxContainer;
                btnImage1.ImageIndex = ImageSixteenShadow.DocumentView;
                                #endregion
                                #region Row 2 of the container
                                //Add a lookup at row 2 - column 1 of gbxContainer container
                                 ZLookUpControl lkCivility = new ZLookUpControl(Mode.Under | Mode.WidthFixed, new Source("lkCivility1"), 130);
                lkCivility.Parent = gbxContainer;
                                //Add a label at row 2 - column 2 of gbxContainer container
                                 ZLabel lblLanguage = new ZLabel(Mode.Right, "lblLanguage1", "Language");
                lblLanguage.Parent = gbxContainer;
                                //Add a lookup at row 2 - column 3 of gbxContainer container
                                 ZLookUpControl lkLanguage = new ZLookUpControl(Mode.Right | Mode.WidthFixed, new Source("lkLanguage1"), 90);
                lkLanguage.Parent = gbxContainer;
                                #endregion
                                return gbxContainer;
                
            }
                                /// <summary>
                                /// Create a control group whose Row 1 applied Mode.Right | Mode.Continuous
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateGroupWithRow1AppliedModeRightAndContinuous(IContainer parent)
            {
                                //Create a groupbox container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(null, //Control Mode
                                "ccControlContainer", //Control Key
                                "Mode.Right | Mode.Continuous" //Group box name
                                              );
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxContainer.ForeColor = Color.FromRGB(196, 98, 0);
                gbxContainer.BorderColor = Color.FromRGB(196, 98, 0);
                gbxContainer.Font = new Font("Tahoma", 8.5, FontStyle.Bold);
                                #region Row 1 of the container
                                //Add a textbox at row 1 - column 1 of gbxContainer container 
                                 ZTextBox tbxReference = new ZTextBox(Mode.Under | Mode.WidthFixed, new Source("tbxReference"), 130);
                tbxReference.Parent = gbxContainer;
                                //Add an image button next to the tbxReference but not placed in a new column of gbxContainer container
                                //In this case, the control is additionaly applied Mode.Continuous
                                 ZButton btnImage = new ZButton(Mode.Right | Mode.Contiguous, "btnImage", "");
                btnImage.Parent = gbxContainer;
                btnImage.ImageIndex = ImageSixteenShadow.NoteYellow;
                                //Add an image button next to the btnImage but not placed in a new column of gbxContainer container
                                //In this case, the control is additionaly applied Mode.Continuous
                                 ZButton btnImage1 = new ZButton(Mode.Right | Mode.Contiguous, "btnImage1", "");
                btnImage1.Parent = gbxContainer;
                btnImage1.ImageIndex = ImageSixteenShadow.DocumentView;
                                #endregion
                                #region Row 2 of the container
                                //Add a lookup at row 2 - column 1 of gbxContainer container
                                 ZLookUpControl lkCivility = new ZLookUpControl(Mode.Under | Mode.WidthFixed, new Source("lkCivility"), 130);
                lkCivility.Parent = gbxContainer;
                                //Add a label at row 2 - column 2 of gbxContainer container
                                 ZLabel lblLanguage = new ZLabel(Mode.Right, "lblLanguage", "Language");
                lblLanguage.Parent = gbxContainer;
                                //Add a lookup at row 2 - column 3 of gbxContainer container
                                 ZLookUpControl lkLanguage = new ZLookUpControl(Mode.Right | Mode.WidthFixed, new Source("lkLanguage"), 90);
                lkLanguage.Parent = gbxContainer;
                                #endregion
                                return gbxContainer;
            }
        }
    }
    

  • FixedMode FixedModeFixedMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class FixedModeLayoutsForm : ZForm
        {
                                public FixedModeLayoutsForm()
            {
                                this.Text = "Fixed Mode";
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateControls(IContainer parent)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                ControlContainer ccContainer = new ControlContainer(Mode.Under | Mode.HeightFixed, "cc");
                ccContainer.Parent = parent;
                ccContainer.BackColor = Color.Transparent;
                                #region Row 1 of the container
                                //Add a label at row 1 - column 1 of in ccContainer container
                                 ZLabel lblNote = new ZLabel(Mode.Under, "lblNote", "Note");
                lblNote.Parent = ccContainer;
                                //Add a textbox at row 1 - column 2 of ccContainer container
                                //Mode.Fixed means that the width or height of the control could be set to a particular value and
                                //not changed even though the form is resized.
                                 ZTextBox tbxNote = new ZTextBox(Mode.Right | Mode.Fixed, new Source("tbxNote"), null);
                tbxNote.Parent = ccContainer;
                tbxNote.Multiline = true;
                tbxNote.Width = 190; //Set width of tbxNote
                tbxNote.Height = 60; //Set height of tbxNote
                tbxNote.ScrollBars = ScrollBars.Both;
                                #endregion
                                #region Row 2 of the container
                                //Add a label at row 2 - column 1 of ccContainer container
                                 ZLabel lblCreatedBy = new ZLabel(null, "lblCreatedBy", "Created by"); //null is equivalent to Mode.Under
                lblCreatedBy.Parent = ccContainer;
                                //Add a dropDownButton at row 2 - column 2 of ccContainer container 
                                 ZDropDownButton ddUsers = new ZDropDownButton(Mode.Right | Mode.Fixed, new Source("ddUsers"), null);
                ddUsers.Parent = ccContainer;
                ddUsers.Width = 190; //Set width of ddUsers, this value is never not changed during form lifeline.
                ddUsers.ButtonText = "Select a user";
                ddUsers.Items.Add(new ListItem("David", "Key1"));
                ddUsers.Items.Add(new ListItem("Susan", "key2"));
                                #endregion
                                #region Row 3 of the container
                                //Add a label at row 3 - column 1 of ccContainer container
                                 ZLabel lblCreatedDate = new ZLabel(null, "lblCreatedDate", "Created date");
                lblCreatedDate.Parent = ccContainer;
                                //Add a DatePicker at row 3 - column 2 of ccContainer container
                                 ZDatePicker dpCreatedDate = new ZDatePicker(Mode.Right | Mode.Fixed, new Source("dpCreatedDate"), null);
                dpCreatedDate.Parent = ccContainer;
                dpCreatedDate.Width = 190; //Set width of dpCreatedDate
                dpCreatedDate.Value = DateTime.Now;
                                #endregion
                                //Summary
                                //  Mode.Fixed is the combination of Mode.WidthFixed and Mode.HeightFixed
                                //      + So, the height or width of a control could be set to a particular value manually.
                                //      + When the form is resized, the control is fixed, i.e., the size of control is the not changed 
                                //      according to new size of the form.
                                return ccContainer;
            }
        }
    }
    

  • HeightFixedMode HeightFixedModeHeightFixedMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class HeightFixedModeLayoutsForm : ZForm
        {
                                public HeightFixedModeLayoutsForm()
            {
                                this.Text = "HeightFixed Mode";
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateControls(IContainer parent)
            {
                                //Create a control container. A container is considered as a table, having rows and columns. 
                                //If a container is HeightFixed, it means:
                                //  (1) The container height is calculated by sum of child-containers' height.
                                //  (2) All child-containers are also applied as HeightFixed by default. 
                ControlContainer ccContainer = new ControlContainer(Mode.Under | Mode.HeightFixed, "cc");
                ccContainer.Parent = parent;
                ccContainer.BackColor = Color.Transparent;
                                #region GroupBox 1
                                //Add a child groupbox at row 1 - column 1 of ccContainer container
                                //The groupbox mode is auto underlying set to HeightFixed because its parent, ccContainer container, is HeightFixed.
                                 ZGroupBox gbxUp = new ZGroupBox(Mode.Under, "gbxUp", "HeightFixed");
                gbxUp.Parent = ccContainer;
                gbxUp.BackColor = Color.Transparent;
                gbxUp.Parent = ccContainer;
                gbxUp.ForeColor = Color.FromRGB(48, 137, 249);
                gbxUp.BorderColor = Color.FromRGB(48, 137, 249);
                gbxUp.Height = 100; //Set height of the groupbox
                                //Add a label at row 1 - column 1 in gbxUp container 
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Please resize the form to have a new layout view");
                lblInfo.Parent = gbxUp;
                                #endregion
                                #region GroupBox 2
                                //Add a child groupbox at row 2 - column 1 of ccContainer container
                                //Tips: Even though the Devs set the groupbox Mode.Under | Mode.HeightResizable, the groupbox is still HeightFixed
                                 ZGroupBox gbxDown = new ZGroupBox(Mode.Under, "gbxDown", "HeightFixed");
                gbxDown.Parent = ccContainer;
                gbxDown.BackColor = Color.Transparent;
                gbxDown.Parent = ccContainer;
                gbxDown.ForeColor = Color.FromRGB(253, 101, 0);
                gbxDown.BorderColor = Color.FromRGB(253, 101, 0);
                                //Add a gridview at row 1 - column 1 of gbxDown container 
                                 ZGridView grvUser = new ZGridView(Mode.Under, "grv", null, null);
                grvUser.Parent = gbxDown;
                grvUser.Height = 130;
                grvUser.RowHeadersVisible = false;
                grvUser.ColumnHeadersHeight = 32;
                                //Add a column in grvUser gridview. By default, the mode of the column is WidthFixed.
                                 ZGridViewColumn col = new ZGridViewColumn("col1", "User name", new ZTextBox(null, new Source("Column1"), null));
                col.Width = 90;
                grvUser.Columns.Add(col);
                                //Add a column in grvUser gridview. By default, the mode of the column is WidthFixed.
                col = new ZGridViewColumn("col2", "Sex", new ZTextBox(null, new Source("Column2"), null));
                col.Width = 40;
                grvUser.Columns.Add(col);
                                //Add a column grvUser gridview. By default, the mode of the column is WidthFixed
                col = new ZGridViewColumn("col3", "Created Date", new ZTextBox(null, new Source("Column3"), null));
                                //Reset mode of the column to WidthResizable. 
                                //It makes sure the width of this column is auto extended to the right edge of the gridview
                col.ControlMode = Mode.WidthResizable;
                grvUser.Columns.Add(col);
                                //When an user resizes the width of the form, column 3's will be auto changed according to the new form's.
                                //However, column 1's and column 2's are not.
                                #endregion
                                //Summary:
                                //  Mode.HeightFixed means that
                                //      + The height of a control could be set to a particular value manually.
                                //      + When a user changes size of the form, the control height is fixed, i.e., the control's is the 
                                //      not changed according to new form's.
                                return ccContainer;
            }
        }
    }
    

  • HeightResizableMode HeightResizableModeHeightResizableMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class HeightResizableModeLayoutsForm : ZForm
        {
                                public HeightResizableModeLayoutsForm()
            {
                                this.Text = "HeightResizable Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateControls(IContainer parent)
            {
                                this.CreateTopAlignmentGroupBox(parent, "Top");
                
                                this.CreateMiddleAligmentGroupBox(parent, "Middle");
                
                                this.CreateBottomAligmentGroupBox(parent, "Bottom");
                                //Summary:
                                //  Mode.HeightResizable means that
                                //      + The height of a control is changed automatically if the form is resized.
                                //      + Based on Mode.HeightResizable, we could align control or group of control whose Mode is Fixed or HeightFixed
            }
                                /// <summary>
                                /// Control in groupbox is aligned at top
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateTopAlignmentGroupBox(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Top aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxTop" + key, "");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.YMargin = 0;
                gbxTop.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxTop container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxTop;
                imgBox.ResourceName = ImageThirtyTwoShadow.Box.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container 
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxBottom" + key, "HeightResizable");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.ForeColor = Color.FromRGB(0, 128, 64);
                gbxBottom.BorderColor = Color.FromRGB(0, 128, 64);
            }
                                /// <summary>
                                /// Control is groupbox is aligned at middle
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateMiddleAligmentGroupBox(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Middle aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container 
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxTop" + key, "HeightResizable");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxTop.ForeColor = Color.FromRGB(196, 98, 0);
                gbxTop.BorderColor = Color.FromRGB(196, 98, 0);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container 
                                 ZGroupBox gbxMiddle = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxMiddle" + key, "");
                gbxMiddle.Parent = gbxContainer;
                gbxMiddle.ShowBorder = false;
                gbxMiddle.BackColor = Color.Transparent;
                gbxMiddle.YMargin = 0;
                                //Add an image box at row 1 - column 1 of gbxMiddle container
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxMiddle;
                imgBox.ResourceName = ImageThirtyTwoShadow.Calculator.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 3 - column 1 of gbxContainer container 
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxBottom" + key, "HeightResizable");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxBottom.ForeColor = Color.FromRGB(196, 98, 0);
                gbxBottom.BorderColor = Color.FromRGB(196, 98, 0);
            }
                                /// <summary>
                                /// Control in groupbox is aligned at bottom
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateBottomAligmentGroupBox(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Bottom aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxTop" + key, "HeightResizable");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxTop.ForeColor = Color.FromRGB(0, 128, 64);
                gbxTop.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container 
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxBottom" + key, "");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.YMargin = 0;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxBottom container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxBottom;
                imgBox.ResourceName = ImageThirtyTwoShadow.Earth.Name;
                imgBox.Size = new Size(32, 32);
            }
        }
    }
    

  • InvisibleMode InvisibleModeInvisibleMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class InvisibleModeLayoutsForm : ZForm
        {
                                public int autoKey = 1;
                                public Color backCellColor = Color.FromRGB(238, 245, 255);
                                public ZGroupBox gbxInvisible1, gbxInvisible2;
                                public InvisibleModeLayoutsForm()
            {
                                this.Text = "Invisible Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.XMargin = 0;
                                this.YMargin = 0;
                CreateControls(this);
            }
                                public void CreateControls(IContainer parent)
            {
                ControlContainer ccInfo = new ControlContainer(Mode.Under | Mode.HeightFixed, "ccInfo");
                ccInfo.Parent = parent;
                ccInfo.BackColor = Color.Transparent;
                                //Add a label in at new row of parent container
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Orange-bordered cells are applied with Mode.Invisible. If the Invisble property is False, they are hidden.");
                lblInfo.Parent = ccInfo;
                lblInfo.Multiline = true;
                                //Add a container
                                 ZGroupBox gbxContainer = this.CreateCell(parent, Mode.Under, null, Color.FromRGB(0, 128, 64), Color.Transparent, autoKey++);
                gbxContainer.Parent = ccInfo;
                gbxContainer.ShowBorder = false;
                gbxContainer.Text = "Mode.Invisible";
                                #region Row 1
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, 60, Color.Black, backCellColor, autoKey++);
                                this.gbxInvisible1 = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed | Mode.Invisible, 60, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                                this.gbxInvisible1.BorderSize = 2;
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, 60, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, 60, Color.Black, backCellColor, autoKey++);
                                #endregion
                                #region Row 2
                                this.gbxInvisible2 = this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed | Mode.Invisible, 150, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                                this.gbxInvisible2.BorderSize = 2;
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, 60, Color.Black, backCellColor, autoKey++);
                                #endregion
                                //Invisble the groupbox
                                //this.gbxInvisible1.Visible = false;
                                //this.gbxInvisible2.Visible = false;
                
            }
                                /// <summary>
                                /// Create control a sample group control
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="mode"></param>
                                /// <param name="width"></param>
                                /// <param name="color"></param>
                                /// <param name="key"></param>
                                /// <returns></returns>
                                public ZGroupBox CreateCell(IContainer parent, Mode mode, int? width, Color borderColor, Color backColor, int key)
            {
                                //Add a groupbox, which is considered as a cell in groupbox parent
                                 ZGroupBox gbxControl = new ZGroupBox(mode, "gbxControl" + key.ToString(), "");
                gbxControl.Parent = parent;
                gbxControl.BackColor = backColor;
                gbxControl.ShowBorder = true;
                gbxControl.BorderColor = borderColor;
                gbxControl.ForeColor = borderColor;
                gbxControl.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxControl.Width = width;
                gbxControl.Font = new Font("Tahoma", 8.5, FontStyle.Bold);
                gbxControl.Round = 10;
                gbxControl.Height = 25;
                                return gbxControl;
            }
        }
    }
    

  • OverMode OverModeOverMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class OverModeLayoutsForm : ZForm
        {
                                public ZGroupBox gbxGroup1, gbxGroup2, gbxGroup3;
                                public OverModeLayoutsForm()
            {
                                this.Text = "OverMode Mode";
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateControls(IContainer parent)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                ControlContainer ccContainer = new ControlContainer(Mode.Under | Mode.HeightFixed, "cc");
                ccContainer.BackColor = Color.Transparent;
                                #region Introduction
                                //Add a child container ccIntro. In this container, it contains two-sub containers including ccLabel and ccButtons
                                //ccIntro is placed at row 1 - column 1 of ccContainer container.
                ControlContainer ccIntro = new ControlContainer(Mode.Under | Mode.HeightFixed, "ccIntro");
                                //ccIntro is set to Mode.HeightFixed, making two-sub containers HeightFixed automatically
                ccIntro.Parent = ccContainer;
                ccIntro.BackColor = Color.Transparent;
                                //Add a child container at row 1 - column 1 of ccIntro container.
                                //The container is used to show the introduction label
                ControlContainer ccLabel = new ControlContainer(Mode.Under, "ccLabel");
                ccLabel.Parent = ccIntro;
                ccLabel.BackColor = Color.Transparent;
                ccLabel.YMargin = 0;
                                //Add a label at row 1 - column 1 of ccLabel container
                                 ZLabel lblIntro = new ZLabel(Mode.Under, "lblIntro", "Click on buttons to show Overlaped button groups");
                lblIntro.Parent = ccLabel;
                lblIntro.BackColor = Color.Transparent;
                                //Add a child container at row 2 - column 1 of ccIntro container 
                                //The container is used to show 3 buttons
                ControlContainer ccButtons = new ControlContainer(Mode.Under, "ccButtons");
                ccButtons.Parent = ccIntro;
                ccButtons.YMargin = 0;
                ccButtons.BackColor = Color.Transparent;
                                //Add a button at row 1 - column 1 of in ccButtons container
                                 ZButton btnGroup1 = new ZButton(Mode.Under, "btnGroup1", "Group 1");
                btnGroup1.Parent = ccButtons;
                btnGroup1.ImageIndex = ImageSixteenShadow.TruckRed;
                btnGroup1.Width = 60;
                btnGroup1.Click += new ZEventHandler(btnGroup1_Click);
                                //Add a button at row 1 - column 2 of ccButtons container.
                                 ZButton btnGroup2 = new ZButton(Mode.Right, "btnGroup2", "Group 2");
                btnGroup2.Parent = ccButtons;
                btnGroup2.ImageIndex = ImageSixteenShadow.TableRow;
                btnGroup2.Width = 60;
                btnGroup2.Click += new ZEventHandler(btnGroup2_Click);
                                //Add a button at row 1 - column 3 of ccButtons container, 
                                 ZButton btnGroup3 = new ZButton(Mode.Right, "btnGroup3", "Group 3");
                btnGroup3.Parent = ccButtons;
                btnGroup3.ImageIndex = ImageSixteenShadow.Box;
                btnGroup3.Width = 60;
                btnGroup3.Click += new ZEventHandler(btnGroup3_Click);
                                #endregion
                                #region Over mode
                                #region Group button 1
                                //Add a child at row 1 - column 2 of ccContainer container. 
                                //The groupbox1 is next to ccIntro container.
                                this.gbxGroup1 = new ZGroupBox(Mode.Right, "gbxGroup1", "Group 1");
                                this.gbxGroup1.Parent = ccContainer;
                                this.gbxGroup1.LabelStyle = GroupBoxLabelStyle.CenterBottom;
                                this.gbxGroup1.BackColor = Color.Transparent;
                                this.gbxGroup1.LabelTopBackColor = new Color(249, 198, 164);
                                this.gbxGroup1.LabelBottomBackColor = new Color(244, 157, 100);
                                this.gbxGroup1.BorderColor = new Color(249, 198, 164);
                                //Add 2 buttons in the gbxGroup1
                                this.CreateGroupButtons(gbxGroup1, ImageThirtyTwoShadow.TruckRed, "key1");
                                #endregion
                                #region Group button 2
                                //Add a child groupbox which is overlapped with gbxGroup1.
                                //So the new groupbox is placed at row 1 - column 2 of ccContainer container
                                this.gbxGroup2 = new ZGroupBox(Mode.Right | Mode.Over, "gbxGroup2", "Group 2");
                                this.gbxGroup2.Parent = ccContainer;
                                this.gbxGroup2.LabelStyle = GroupBoxLabelStyle.CenterBottom;
                                this.gbxGroup2.BackColor = Color.Transparent;
                                this.gbxGroup2.LabelTopBackColor = new Color(108, 108, 183);
                                this.gbxGroup2.LabelBottomBackColor = new Color(175, 175, 216);
                                this.gbxGroup2.BorderColor = new Color(108, 108, 183);
                                //Add 2 buttons in the gbxGroup2
                                this.CreateGroupButtons(gbxGroup2, ImageThirtyTwoShadow.TableRow, "key2");
                                #endregion
                                #region Group button 3
                                //Add a child groupbox which is overlapped with gbxGroup2.
                                //So the new groupbox is placed at row 1 - column 2 of ccContainer container
                                this.gbxGroup3 = new ZGroupBox(Mode.Right | Mode.Over, "gbxGroup3", "Group 3");
                                this.gbxGroup3.Parent = ccContainer;
                                this.gbxGroup3.LabelStyle = GroupBoxLabelStyle.CenterBottom;
                                this.gbxGroup3.BackColor = Color.Transparent;
                                this.gbxGroup3.LabelTopBackColor = new Color(173, 90, 90);
                                this.gbxGroup3.LabelBottomBackColor = new Color(214, 171, 171);
                                this.gbxGroup3.BorderColor = new Color(173, 90, 90);
                                //Add 2 buttons in the gbxGroup3
                                this.CreateGroupButtons(gbxGroup3, ImageThirtyTwoShadow.Box, "key3");
                                //For now, there are two groupboxes which are overlapped with gbxGroup1, i.e., gbxGroup2 and gbxGroup3.
                                //It means gbxGroup1 could be replaced by gbxGroup2 or gbxGroup3.
                                #endregion
                                #endregion
                                //Summary
                                //  Mode.Over means that
                                //      + A control or group of control could be overlaped with another control or group of control.
                                //      + At a specific time, there is only one control or group of control is visible while the others are invisible.
                                return ccContainer;
            }
                                /// <summary>
                                /// Show group button 3
                                /// </summary>
                                /// <param name="sender"></param>
                                /// <param name="e"></param>
                                protected void btnGroup3_Click(object sender, ZEventArgs e)
            {
                                //Invisble all Mode.Over-relating control groups.
                                this.InvisbleAllGroupButtons();
                                //Set groupbox3 visible
                                this.gbxGroup3.Visible = true;
            }
                                /// <summary>
                                /// Show group button 2
                                /// </summary>
                                /// <param name="sender"></param>
                                /// <param name="e"></param>
                                protected void btnGroup2_Click(object sender, ZEventArgs e)
            {
                                //Invisble all Mode.Over-relating control groups.
                                this.InvisbleAllGroupButtons();
                                //Set groupbox2 visible
                                this.gbxGroup2.Visible = true;
            }
                                /// <summary>
                                /// Show group button 1
                                /// </summary>
                                /// <param name="sender"></param>
                                /// <param name="e"></param>
                                protected void btnGroup1_Click(object sender, ZEventArgs e)
            {
                                //Invisble all Mode.Over-relating control groups.
                                this.InvisbleAllGroupButtons();
                                //Set groupbox1 visible
                                this.gbxGroup1.Visible = true;
            }
                                /// <summary>
                                /// Invisible all Mode.Over-relating group buttons 
                                /// </summary>
                                protected void InvisbleAllGroupButtons()
            {
                                this.gbxGroup1.Visible = false;
                                this.gbxGroup2.Visible = false;
                                this.gbxGroup3.Visible = false;
            }
                                /// <summary>
                                /// Create group button
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="image"></param>
                                protected void CreateGroupButtons(IContainer parent, BaseImage image, string key)
            {
                                // Add a ZButton at row 1 - column 1 of parent container 
                                 ZButton btnEdit = new ZButton(null, "btnEdit" + key, "Edit");
                btnEdit.Parent = parent;
                btnEdit.ButtonStyle = ButtonStyle.Customized;
                btnEdit.ToolTip = new ZToolTip();
                btnEdit.ToolTip.ShowFooterLine = false;
                btnEdit.ToolTip.Header.Text = "Edit";
                btnEdit.TextAlign = ContentAlignment.MiddleCenter;
                btnEdit.TextImageRelation = TextImageRelation.ImageAboveText;
                btnEdit.ImageIndex = image;
                btnEdit.AddSubImage(ImageSixteenShadow.FloppyDiskWindow, ContentAlignment.BottomRight);
                                // Add a ZButton at row 1 - column 2 of parent container
                                 ZButton btnFilter = new ZButton(Mode.Right, "btnFilter" + key, "Filter");
                btnFilter.Parent = parent;
                btnFilter.ButtonStyle = ButtonStyle.Customized;
                btnFilter.ToolTip = new ZToolTip();
                btnFilter.ToolTip.ShowFooterLine = false;
                btnFilter.ToolTip.Header.Text = "Filter";
                btnFilter.TextAlign = ContentAlignment.MiddleCenter;
                btnFilter.TextImageRelation = TextImageRelation.ImageAboveText;
                btnFilter.ImageIndex = image;
                btnFilter.AddSubImage(ImageSixteenShadow.UndoRed, ContentAlignment.BottomRight);
            }
        }
    }
    

  • RightAlignMode RightAlignModeRightAlignMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class RightAlignModeLayoutsForm : ZForm
        {
                                public int cellWidth = 60;
                                public int autoKey = 1;
                                public Color backCellColor = Color.FromRGB(238, 245, 255);
                                public RightAlignModeLayoutsForm()
            {
                                this.Text = "RightAlign Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.XMargin = 0;
                                this.YMargin = 0;
                                this.CreateControls(this);
            }
                                public void CreateControls(IContainer parent)
            {
                ControlContainer ccInfo = new ControlContainer(Mode.Under | Mode.HeightFixed, "ccInfo");
                ccInfo.Parent = parent;
                ccInfo.BackColor = Color.Transparent;
                                //Add a label in at new row of parent container
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Cells are applied Continuous mode. For this case, the last border-colored cell on each \nrow is additional applied Mode value for right alignment.");
                lblInfo.Parent = ccInfo;
                lblInfo.Multiline = true;
                ControlContainer ccDistance = new ControlContainer(Mode.Under | Mode.HeightFixed, "ccDistance");
                ccDistance.Parent = parent;
                ccDistance.Height = 10;
                ccDistance.BackColor = Color.Transparent;
                                this.CreateWidthFixedRightAlignGroupBox(parent);
                ccDistance = new ControlContainer(Mode.Under | Mode.HeightFixed, "ccDistance1");
                ccDistance.Parent = parent;
                ccDistance.Height = 10;
                ccDistance.BackColor = Color.Transparent;
                                this.CreateWidthFixedGroupBox(parent);
                                //Summary
                                //  Mode.Fixed is the combination of Mode.WidthFixed and Mode.HeightFixed
                                //      + So, the height or width of a control could be set to a particular value manually.
                                //      + When the form is resized, the control is fixed, i.e., the size of control is the not changed 
                                //      according to new size of the form.
            }
                                /// <summary>
                                /// Create groupbox in which the last cell on each row is applied Mode.WidthFixed | Mode.RightAlign
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateWidthFixedRightAlignGroupBox(IContainer parent)
            {
                                //Add a container
                                 ZGroupBox gbxContainer = this.CreateCell(parent, Mode.Under, null, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                gbxContainer.ShowBorder = false;
                gbxContainer.Text = "WidthFixed | RightAlign";
                                #region Row 1
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                 ZGroupBox gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed | Mode.RightAlign, cellWidth, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
                                #region Row 2
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed | Mode.RightAlign, 150, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
                                #region Row 3
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed | Mode.RightAlign, 100, Color.FromRGB(196, 98, 0), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
            }
                                /// <summary>
                                /// Create groupbox in which the last cell on each row is applied Mode.WidthFixed
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateWidthFixedGroupBox(IContainer parent)
            {
                                //Create a container
                                 ZGroupBox gbxContainer = this.CreateCell(parent, Mode.Under, null, Color.FromRGB(0, 128, 64), Color.Transparent, autoKey++);
                gbxContainer.ShowBorder = false;
                gbxContainer.Text = "WidthFixed";
                                #region Row 1
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                 ZGroupBox gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.FromRGB(0, 128, 64), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
                                #region Row 2
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, 150, Color.FromRGB(0, 128, 64), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
                                #region Row 3
                                this.CreateCell(gbxContainer, Mode.Under | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                                this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, cellWidth, Color.Black, backCellColor, autoKey++);
                gbxCell = this.CreateCell(gbxContainer, Mode.Right | Mode.Contiguous | Mode.WidthFixed, 40, Color.FromRGB(0, 128, 64), Color.Transparent, autoKey++);
                gbxCell.BorderSize = 2;
                                #endregion
            }
                                /// <summary>
                                /// Create control a sample group control
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="mode"></param>
                                /// <param name="width"></param>
                                /// <param name="color"></param>
                                /// <param name="key"></param>
                                /// <returns></returns>
                                public ZGroupBox CreateCell(IContainer parent, Mode mode, int? width, Color borderColor, Color backColor, int key)
            {
                                //Add a groupbox, which is considered as a cell in groupbox parent
                                 ZGroupBox gbxControl = new ZGroupBox(mode, "gbxControl" + key.ToString(), "");
                gbxControl.Parent = parent;
                gbxControl.BackColor = backColor;
                gbxControl.ShowBorder = true;
                gbxControl.BorderColor = borderColor;
                gbxControl.ForeColor = borderColor;
                gbxControl.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxControl.Width = width;
                gbxControl.Font = new Font("Tahoma", 8.5, FontStyle.Bold);
                gbxControl.Round = 10;
                                return gbxControl;
            }
        }
    }
    

  • RightMode RightModeRightMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class RightModeLayoutsForm : ZForm
        {
                                public RightModeLayoutsForm()
            {
                                this.Text = "Right Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateControls(IContainer parent)
            {
                Color color = Color.FromRGB(70, 149, 255);
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                
                                 ZGroupBox gbxSearch = new ZGroupBox(Mode.Under, "gbxSearch", "Search");
                gbxSearch.Parent = parent;
                gbxSearch.BackColor = Color.Transparent;
                gbxSearch.ForeColor = color;
                gbxSearch.BorderColor = color;
                gbxSearch.Font = new Font("Tahoma", 8.5, FontStyle.Bold);
                                 ZComboBox cmbSearchType = new ZComboBox(Mode.Under | Mode.WidthFixed, new Source("cmbSearchType"), 100);
                cmbSearchType.Parent = gbxSearch;
                cmbSearchType.Items.Add(new ListItem("Type 1", "Type1"));
                cmbSearchType.Items.Add(new ListItem("Type 2", "Type2"));
                                 ZTextBox tbxSearch = new ZTextBox(Mode.Right, new Source("tbxSearch"), null);
                tbxSearch.Width = 250; //Minimum width of textbox
                tbxSearch.Parent = gbxSearch;
                                 ZButton btnUp = new ZButton(Mode.Right, "btnUp", "");
                btnUp.Parent = gbxSearch;
                btnUp.ButtonStyle = ButtonStyle.Customized;
                btnUp.ImageIndex = ImageSixteenShadow.UpArrow;
                                 ZButton btnDown = new ZButton(Mode.Right, "btnDown", "");
                btnDown.Parent = gbxSearch;
                btnDown.ButtonStyle = ButtonStyle.Customized;
                btnDown.ImageIndex = ImageSixteenShadow.DownArrow;
                                 ZButton btnFilter = new ZButton(Mode.Right, "btnFilter", "");
                btnFilter.Parent = gbxSearch;
                btnFilter.ButtonStyle = ButtonStyle.Customized;
                btnFilter.ImageIndex = ImageSixteenShadow.Funnel;
                                 ZGroupBox gbxSelection = new ZGroupBox(Mode.Right | Mode.WidthFixed, "gbxSelection", "Selection");
                gbxSelection.Parent = parent;
                gbxSelection.BackColor = Color.Transparent;
                gbxSelection.ForeColor = color;
                gbxSelection.BorderColor = color;
                gbxSelection.Font = new Font("Tohoma", 8.5, FontStyle.Bold);
                                 ZComboBox cmbSelection = new ZComboBox(Mode.Under, new Source("cmbSelection"), 100);
                cmbSelection.Parent = gbxSelection;
                cmbSelection.Items.Add(new ListItem("Selection 1", "Selection1"));
                cmbSelection.Items.Add(new ListItem("Selection 2", "Selection2"));
            }
        }
    }
    

  • UnderMode UnderModeUnderMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class UnderModeLayoutsForm : ZForm
        {
                                public UnderModeLayoutsForm()
            {
                                this.Text = "Under Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public ControlContainer CreateControls(IContainer parent)
            {
                                //Create a ControlContainer containing all child controls
                                //A control container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                ControlContainer ccContainer = new ControlContainer(Mode.Under, //Control Mode
                                "ccControlContainer" //Control Key
                                                            );
                ccContainer.Parent = parent;
                ccContainer.BackColor = Color.Transparent; 
                ccContainer.XMargin = 0;
                ccContainer.YMargin = 0;
                Color oddColor = null;
                Color evenColor = Color.FromRGB(176, 209, 255);
                                this.CreateButtonRow(ccContainer, evenColor, ImageThirtyTwoShadow.Key, "License", "0");
                                this.CreateButtonRow(ccContainer, oddColor, ImageThirtyTwoShadow.Businessman, "Preferences", "1");
                                this.CreateButtonRow(ccContainer, evenColor, ImageThirtyTwoShadow.Folder, "Folder \noptions", "2");
                                this.CreateButtonRow(ccContainer, oddColor, ImageThirtyTwoShadow.Earth, "Countries", "3");
                                //Summary:
                                //  (1) Mode.Under means that the created control is placed in a new row of the container parent.
                                //  (2) Mode.Under is equivalent to null value
                                //  (3) If a control is set to Mode.Under, i.e., the mode of control is a combination of 
                                //      Mode.Under | Mode.WidthResizable | Mode.HeightResizable
                                return ccContainer;
            }
                                /// <summary>
                                /// Create row having inner icon
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="imgIcon"></param>
                                /// <param name="txtIcon"></param>
                                /// <param name="key"></param>
                                public IContainer CreateButtonRow(IContainer parent, Color color, BaseImage imgIcon, string txtIcon, string key)
            {
                ControlContainer ccContainer = new ControlContainer(Mode.Under, "ccContainerRow" + key);
                ccContainer.Parent = parent;
                ccContainer.BackColor = color;
                ccContainer.ShowBorder = false;
                ccContainer.XMargin = 10;
                ccContainer.YMargin = 10;
                                 ZButton button = new ZButton(Mode.Under, "button" + key, txtIcon);
                button.Parent = ccContainer;
                button.Width = 80;
                button.ButtonStyle = ButtonStyle.Customized;
                button.TextImageRelation = TextImageRelation.ImageAboveText;
                button.ImageIndex = imgIcon;
                                return ccContainer;
            }
        }
    }
    

  • WidthFixedMode WidthFixedModeWidthFixedMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class WidthFixedModeLayoutsForm : ZForm
        {
                                public WidthFixedModeLayoutsForm()
            {
                                this.Text = "WidthFixed Mode";
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateControls(IContainer parent)
            {
                                //Create a groupbox container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                ControlContainer ccContainer = new ControlContainer(Mode.Under, "ccContainer");
                ccContainer.Parent = parent;
                ccContainer.BackColor = Color.Transparent;
                                #region GroupBox 1
                                //Add a child groupbox at row 1 - column 1 of in ccContainer container.
                                //Because the groupbox mode is WidthFixed, the width of control is not changed even though there is any users' changing form's.
                                 ZGroupBox gbxLeft = new ZGroupBox(Mode.Under | Mode.WidthFixed, "gbxLeft", "WidthFixed");
                gbxLeft.Parent = ccContainer;
                gbxLeft.BackColor = Color.Transparent;
                gbxLeft.Parent = ccContainer;
                gbxLeft.ForeColor = Color.FromRGB(48, 137, 249);
                gbxLeft.BorderColor = Color.FromRGB(48, 137, 249);
                gbxLeft.Width = 100; //Set width of the groupbox
                                //Add a label at row 1 - column 1 of gbxLeft container.
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Please resize the form to have a new layout view");
                lblInfo.Parent = gbxLeft;
                                #endregion
                                #region GroupBox 2
                                //Add a child groupbox at row 1 - column 2 ccContainer container.
                                 ZGroupBox gbxRight = new ZGroupBox(Mode.Right, "gbxRight", "WidthResizable"); //Mode.Right = Mode.HeightResizable | Mode.WidthResizable
                gbxRight.Parent = ccContainer;
                gbxRight.BackColor = Color.Transparent;
                gbxRight.Width = 300; //Initiates the width of groupbox, which is the minimum groupbox's in this case.
                gbxRight.ForeColor = Color.FromRGB(253, 101, 0);
                gbxRight.BorderColor = Color.FromRGB(253, 101, 0);
                                //Add a gridview at row 1 - column 1 of gbxRight container
                                 ZGridView grvUser = new ZGridView(Mode.Under, "grv", null, null);
                grvUser.Parent = gbxRight;
                grvUser.Height = 130;
                grvUser.RowHeadersVisible = false;
                grvUser.ColumnHeadersHeight = 32;
                                //Add a column in grvUser gridview. By default, the mode of the column is WidthFixed
                                 ZGridViewColumn col = new ZGridViewColumn("col1", "User name", new ZTextBox(null, new Source("Column1"), null));
                col.ControlMode = Mode.WidthResizable; //Reset mode to WidthResizable
                grvUser.Columns.Add(col);
                                //Add a column in grvUser gridview. By default, the mode of the column is WidthFixed
                col = new ZGridViewColumn("col2", "Sex", new ZTextBox(null, new Source("Column2"), null));
                col.Width = 40;
                grvUser.Columns.Add(col);
                                //Add a column in grvUser gridview. By default, the mode of the column is WidthFixed
                col = new ZGridViewColumn("col3", "Created Date", new ZTextBox(null, new Source("Column3"), null));
                                //Reset mode to WidthResizable. It makes sure the width of this column is auto extended to the right edge of the gridview
                col.ControlMode = Mode.WidthResizable;
                grvUser.Columns.Add(col);
                                //When an user resizes the width of the form, column 1's and column 3's will be auto changed according to the new form's.
                                //However, the column 2's is not.
                                #endregion
                                //Summary:
                                //  Mode.WidthFixed means that
                                //      + The width of a control could be set to a particular value manually.
                                //      + When a user changes size of the form, the control width is fixed, i.e., the width of the control is 
                                //      not changed according to new form's.
                                return ccContainer;
            }
        }
    }
    

  • WidthResizableMode WidthResizableModeWidthResizableMode
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class WidthResizableModeLayoutsForm : ZForm
        {
                                public WidthResizableModeLayoutsForm()
            {
                                this.Text = "WidthResizable Mode";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateControls(IContainer parent)
            {
                                this.CreateLeftAlignment(parent, "Left");
                                this.CreateCenterAlignment(parent, "Center");
                                this.CreateRightAlignment(parent, "Right");
                                //Summary:
                                //  Mode.WidthResizable means that
                                //      + The width of a control is changed automatically if the form is resized.
                                //      + Based on Mode.WidthResizable, we could align control or group of control whose Mode is Fixed or WidthFixed
            }
                                /// <summary>
                                /// Control in groupbox is aligned at left
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateLeftAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Left aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer 
                                 ZGroupBox gbxLeft = new ZGroupBox(Mode.Under | Mode.WidthFixed, "gbxLeft" + key, "");
                gbxLeft.Parent = gbxContainer;
                gbxLeft.BackColor = Color.Transparent;
                gbxLeft.YMargin = 0;
                gbxLeft.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxLeft container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxLeft;
                imgBox.ResourceName = ImageThirtyTwoShadow.Box.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 1 - column 2 of gbxContainer container 
                                 ZGroupBox gbxRight = new ZGroupBox(Mode.Right | Mode.WidthResizable, "gbxRight" + key, "WidthResizable");
                gbxRight.Parent = gbxContainer;
                gbxRight.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxRight.BackColor = Color.Transparent;
                gbxRight.ForeColor = Color.FromRGB(0, 128, 64);
                gbxRight.BorderColor = Color.FromRGB(0, 128, 64);
            }
                                /// <summary>
                                /// Control in groupbox is aligned at center
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateCenterAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Center aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container 
                                 ZGroupBox gbxLeft = new ZGroupBox(Mode.Under | Mode.WidthResizable, "gbxLeft" + key, "WidthResizable");
                gbxLeft.Parent = gbxContainer;
                gbxLeft.BackColor = Color.Transparent;
                gbxLeft.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxLeft.ForeColor = Color.FromRGB(196, 98, 0);
                gbxLeft.BorderColor = Color.FromRGB(196, 98, 0);
                                //Add a child groupbox at row 1 - column 2 of gbxContainer container 
                                 ZGroupBox gbxCenter = new ZGroupBox(Mode.Right | Mode.WidthFixed, "gbxCenter" + key, "");
                gbxCenter.Parent = gbxContainer;
                gbxCenter.ShowBorder = false;
                gbxCenter.BackColor = Color.Transparent;
                gbxCenter.YMargin = 0;
                                //Add an image box at row 1 - column 1 of gbxCenter container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxCenter;
                imgBox.ResourceName = ImageThirtyTwoShadow.Calculator.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 1 - column 3 of gbxContainer container 
                                 ZGroupBox gbxRight = new ZGroupBox(Mode.Right | Mode.WidthResizable, "gbxRight" + key, "WidthResizable");
                gbxRight.Parent = gbxContainer;
                gbxRight.BackColor = Color.Transparent;
                gbxRight.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxRight.ForeColor = Color.FromRGB(196, 98, 0);
                gbxRight.BorderColor = Color.FromRGB(196, 98, 0);
            }
                                /// <summary>
                                /// Control in groupbox is aligned at right
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateRightAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Right aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container
                                 ZGroupBox gbxLeft = new ZGroupBox(Mode.Under | Mode.WidthResizable, "gbxLeft" + key, "WidthResizable");
                gbxLeft.Parent = gbxContainer;
                gbxLeft.BackColor = Color.Transparent;
                gbxLeft.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxLeft.ForeColor = Color.FromRGB(0, 128, 64);
                gbxLeft.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container
                                 ZGroupBox gbxRight = new ZGroupBox(Mode.Right | Mode.WidthFixed, "gbxRight" + key, "");
                gbxRight.Parent = gbxContainer;
                gbxRight.YMargin = 0;
                gbxRight.BackColor = Color.Transparent;
                gbxRight.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of in gbxRight container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxRight;
                imgBox.ResourceName = ImageThirtyTwoShadow.Earth.Name;
                imgBox.Size = new Size(32, 32);
            }
        }
    }
    

Here are some demos of Mode utilization

  • NestedLayout NestedLayoutNestedLayout
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class NestedLayoutLayoutsForm : ZForm
        {
                                public NestedLayoutLayoutsForm()
            {
                                this.Text = "Nested Layout";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.XMargin = 0;
                                this.YMargin = 0;
                
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <returns></returns>
                                public IContainer CreateControls(IContainer parent)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                ControlContainer ccContainer = new ControlContainer(Mode.Under, "cc");
                ccContainer.Parent = parent;
                ccContainer.BackColor = Color.Transparent;
                ccContainer.BorderSize = 2;
                                //Add a child groupbox at row 1 - column 1 of ccContainer container 
                                 ZGroupBox ccHeader = new ZGroupBox(Mode.Under | Mode.HeightFixed, "ccHeader", "HeightFixed - 50px");
                ccHeader.Parent = ccContainer;
                ccHeader.BackColor = Color.Transparent;
                ccHeader.Height = 50;
                ccHeader.LabelStyle = GroupBoxLabelStyle.RightBottom; //Show text of groupbox at Right Bottom corner
                ccHeader.BorderColor = Color.FromRGB(171, 88, 88);
                ccHeader.ForeColor = Color.FromRGB(171, 88, 88);
                                //Add a label at row 1 - column 1 of ccHeader container 
                                 ZLabel lblInfo = new ZLabel(Mode.Under, "lblInfo", "Please resize the form to have a new layout view");
                lblInfo.Parent = ccHeader;
                                //Add a child groupbox at row 2 - column 1 of ccContainer container 
                                 ZGroupBox ccBody = new ZGroupBox(Mode.Under | Mode.HeightResizable, "ccBody", "HeightResizable");
                ccBody.Parent = ccContainer;
                ccBody.BorderColor = Color.Black;
                ccBody.BackColor = Color.Transparent;
                                //Add a child groupbox at row 1 - column 1 of ccBody container 
                                 ZGroupBox ccBodyUp = new ZGroupBox(Mode.Under | Mode.HeightResizable, "ccBodyUp", "HeightResizable");
                ccBodyUp.Parent = ccBody;
                ccBodyUp.Height = 15; //Minimum height of HeightResizable groupbox
                ccBodyUp.BorderColor = Color.FromRGB(0, 128, 64);
                ccBodyUp.ForeColor = Color.FromRGB(0, 128, 64);
                ccBodyUp.LabelStyle = GroupBoxLabelStyle.RightBottom;
                ccBodyUp.BackColor = Color.Transparent;
                                //Add a child groupbox at row 2 - column 1 of ccBody container 
                                 ZGroupBox ccBodyMiddle = new ZGroupBox(Mode.Under | Mode.HeightFixed, "ccBodyMiddle", "HeightFixed");
                ccBodyMiddle.Parent = ccBody;
                ccBodyMiddle.BorderColor = Color.FromRGB(196, 98, 0);
                ccBodyMiddle.ForeColor = Color.FromRGB(196, 98, 0);
                ccBodyMiddle.LabelStyle = GroupBoxLabelStyle.RightBottom;
                ccBodyMiddle.BackColor = Color.Transparent;
                                //Add a label at row 1 - column 1 of ccBodyMiddle container 
                                 ZLabel lblUserName = new ZLabel(Mode.Under , "lblUserName", "User name");
                lblUserName.Parent = ccBodyMiddle;
                                //Add a textbox at row 1 - column 2 of ccBodyMiddle container 
                                 ZTextBox tbxUserName = new ZTextBox(Mode.Right | Mode.WidthFixed, new Source("tbxUserName"), null);
                tbxUserName.Parent = ccBodyMiddle;
                tbxUserName.Width = 70;
                                //Add an imagebox next to tbxUserName but not be placed in new column of ccBodyMiddle container 
                                 ZImageBox imgUserIcon = new ZImageBox(Mode.Right | Mode.Contiguous, "imgUserIcon");
                imgUserIcon.Parent = ccBodyMiddle;
                imgUserIcon.Size = new Size(16, 16);
                imgUserIcon.ResourceName = ImageSixteenShadow.Businessman.Name;
                                //Add a label at row 2 - column 1 of ccBodyMiddle container 
                                 ZLabel lblPassword = new ZLabel(Mode.Under, "lblPassword", "Password");
                lblPassword.Parent = ccBodyMiddle;
                                //Add a textbox at row 2 - column 2 of ccBodyMiddle container 
                                 ZTextBox tbxPassword = new ZTextBox(Mode.Right | Mode.WidthFixed, new Source("tbxPassword"), null);
                tbxPassword.Parent = ccBodyMiddle;
                tbxPassword.Width = 120;
                                //Add a child groupbox at row 3 - column 1 of ccContainer container 
                                 ZGroupBox ccFooter = new ZGroupBox(Mode.Under | Mode.HeightFixed, "ccFooter", "HeightFixed - 30px");
                ccFooter.Parent = ccContainer;
                ccFooter.LabelStyle = GroupBoxLabelStyle.RightBottom;
                ccFooter.Height = 30;
                ccFooter.BackColor = Color.Transparent;
                ccFooter.ForeColor = Color.Blue;
                ccFooter.BorderColor = Color.Blue;
                
                                return ccContainer;
            }
        }
    }
    

  • WidthHeightResizable WidthHeightResizableWidthHeightResizable
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    namespace Winbooks.Documentation.Examples
    {
                                public class WidthHeightResizableLayoutLayoutsForm : ZForm
        {
                                public WidthHeightResizableLayoutLayoutsForm()
            {
                                this.Text = "Width/Height Resizable Layout";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.CreateControls(this);
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                /// <param name="parent"></param>
                                public void CreateControls(IContainer parent)
            {
                                this.CreateMiddleLeftAlignment(parent, "MiddleLeft");
                                this.CreateMiddleCenterAlignment(parent, "MiddleCenter");
                                this.CreateMiddleRightAlignment(parent, "MiddleRight");
                                //Summary: 
                                //      Form layout is designed based on Mode.WidthResizable, Mode.WidthFixed, 
                                //          Mode.HeightResizable and Mode.HeightFixed
            }
                                /// <summary>
                                /// Control in groupbox is aligned at middle left
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateMiddleLeftAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Middle left aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container 
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxTop" + key, "HeightResizable");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxTop.ForeColor = Color.FromRGB(196, 98, 0);
                gbxTop.BorderColor = Color.FromRGB(196, 98, 0);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container 
                                 ZGroupBox gbxMiddle = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxMiddle" + key, "");
                gbxMiddle.Parent = gbxContainer;
                gbxMiddle.BackColor = Color.Transparent;
                gbxMiddle.ShowBorder = false;
                gbxMiddle.YMargin = 0;
                gbxMiddle.XMargin = 0;
                                //Add a child groupbox at row 1 - column 1 of gbxMiddle container 
                                 ZGroupBox gbxMiddleLeft = new ZGroupBox(Mode.Under | Mode.WidthFixed, "gbxMiddleLeft" + key, "");
                gbxMiddleLeft.Parent = gbxMiddle;
                gbxMiddleLeft.BackColor = Color.Transparent;
                gbxMiddleLeft.YMargin = 0;
                gbxMiddleLeft.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxMiddleLeft container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxMiddleLeft;
                imgBox.ResourceName = ImageThirtyTwoShadow.Box.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 1 - column 2 of gbxMiddle container 
                                 ZGroupBox gbxMiddleRight = new ZGroupBox(Mode.Right | Mode.WidthResizable, "gbxMiddleRight" + key, "WidthResizable");
                gbxMiddleRight.Parent = gbxMiddle;
                gbxMiddleRight.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxMiddleRight.BackColor = Color.Transparent;
                gbxMiddleRight.ForeColor = Color.FromRGB(0, 128, 64);
                gbxMiddleRight.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 3 - column 1 of gbxContainer container 
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxBottom" + key, "HeightResizable");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.ForeColor = Color.FromRGB(196, 98, 0);
                gbxBottom.BorderColor = Color.FromRGB(196, 98, 0);
            }
                                /// <summary>
                                /// Control in groupbox is aligned at middle right
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateMiddleCenterAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Middle center aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of  gbxContainer container
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxTop" + key, "HeightResizable");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxTop.ForeColor = Color.FromRGB(196, 98, 0);
                gbxTop.BorderColor = Color.FromRGB(196, 98, 0);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container 
                                 ZGroupBox gbxMiddle = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxMiddle" + key, "");
                gbxMiddle.Parent = gbxContainer;
                gbxMiddle.BackColor = Color.Transparent;
                gbxMiddle.ShowBorder = false;
                gbxMiddle.YMargin = 0;
                gbxMiddle.XMargin = 0;
                                //Add a child groupbox at row 1 - column 1 of gbxMiddle container 
                                 ZGroupBox gbxMiddleLeft = new ZGroupBox(Mode.Under | Mode.WidthResizable, "gbxMiddleLeft" + key, "WidthResizable");
                gbxMiddleLeft.Parent = gbxMiddle;
                gbxMiddleLeft.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxMiddleLeft.BackColor = Color.Transparent;
                gbxMiddleLeft.ForeColor = Color.FromRGB(0, 128, 64);
                gbxMiddleLeft.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 1 - column 2 of gbxMiddle container 
                                 ZGroupBox gbxMiddleCenter = new ZGroupBox(Mode.Right | Mode.WidthFixed, "gbxMiddleCenter" + key, "");
                gbxMiddleCenter.Parent = gbxMiddle;
                gbxMiddleCenter.BackColor = Color.Transparent;
                gbxMiddleCenter.YMargin = 0;
                gbxMiddleCenter.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxMiddleCenter container 
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxMiddleCenter;
                imgBox.ResourceName = ImageThirtyTwoShadow.Calculator.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 1 - column 3 of gbxMiddle container 
                                 ZGroupBox gbxMiddleRight = new ZGroupBox(Mode.Right | Mode.WidthResizable, "gbxMiddleRight" + key, "WidthResizable");
                gbxMiddleRight.Parent = gbxMiddle;
                gbxMiddleRight.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxMiddleRight.BackColor = Color.Transparent;
                gbxMiddleRight.ForeColor = Color.FromRGB(0, 128, 64);
                gbxMiddleRight.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 3 - column 1 of gbxContainer container 
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxBottom" + key, "HeightResizable");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.ForeColor = Color.FromRGB(196, 98, 0);
                gbxBottom.BorderColor = Color.FromRGB(196, 98, 0);
            }
                                /// <summary>
                                /// Control in groupbox is aligned at middle right
                                /// </summary>
                                /// <param name="parent"></param>
                                /// <param name="key"></param>
                                public void CreateMiddleRightAlignment(IContainer parent, string key)
            {
                                //Create a control container
                                //A container is considered as a table, having rows and columns. 
                                //Created child-controls are placed in cells of the table.
                                 ZGroupBox gbxContainer = new ZGroupBox(Mode.Under, "gbxContainer" + key, "Middle right aligment");
                gbxContainer.Parent = parent;
                gbxContainer.BackColor = Color.Transparent;
                gbxContainer.BorderColor = Color.Black;
                                //Add a child groupbox at row 1 - column 1 of gbxContainer container
                                 ZGroupBox gbxTop = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxTop" + key, "HeightResizable");
                gbxTop.Parent = gbxContainer;
                gbxTop.BackColor = Color.Transparent;
                gbxTop.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxTop.ForeColor = Color.FromRGB(196, 98, 0);
                gbxTop.BorderColor = Color.FromRGB(196, 98, 0);
                                //Add a child groupbox at row 2 - column 1 of gbxContainer container
                                 ZGroupBox gbxMiddle = new ZGroupBox(Mode.Under | Mode.HeightFixed, "gbxMiddle" + key, "");
                gbxMiddle.Parent = gbxContainer;
                gbxMiddle.BackColor = Color.Transparent;
                gbxMiddle.ShowBorder = false;
                gbxMiddle.YMargin = 0;
                gbxMiddle.XMargin = 0;
                                //Add a child groupbox at row 1 - column 1 of gbxMiddle container
                                 ZGroupBox gbxMiddleLeft = new ZGroupBox(Mode.Under | Mode.WidthResizable, "gbxMiddleLeft" + key, "WidthResizable");
                gbxMiddleLeft.Parent = gbxMiddle;
                gbxMiddleLeft.LabelStyle = GroupBoxLabelStyle.RightBottom;
                gbxMiddleLeft.BackColor = Color.Transparent;
                gbxMiddleLeft.ForeColor = Color.FromRGB(0, 128, 64);
                gbxMiddleLeft.BorderColor = Color.FromRGB(0, 128, 64);
                                //Add a child groupbox at row 1 - column 2 of gbxMiddle container
                                 ZGroupBox gbxMiddleRight = new ZGroupBox(Mode.Right | Mode.WidthFixed, "gbxMiddleRight" + key, "");
                gbxMiddleRight.Parent = gbxMiddle;
                gbxMiddleRight.BackColor = Color.Transparent;
                gbxMiddleRight.YMargin = 0;
                gbxMiddleRight.ShowBorder = false;
                                //Add an image box at row 1 - column 1 of gbxMiddleRight container
                                 ZImageBox imgBox = new ZImageBox(Mode.Under, "imgBox" + key);
                imgBox.Parent = gbxMiddleRight;
                imgBox.ResourceName = ImageThirtyTwoShadow.Earth.Name;
                imgBox.Size = new Size(32, 32);
                                //Add a child groupbox at row 3 - column 1 of gbxContainer container
                                 ZGroupBox gbxBottom = new ZGroupBox(Mode.Under | Mode.HeightResizable, "gbxBottom" + key, "HeightResizable");
                gbxBottom.Parent = gbxContainer;
                gbxBottom.LabelStyle = GroupBoxLabelStyle.LeftBottom;
                gbxBottom.BackColor = Color.Transparent;
                gbxBottom.ForeColor = Color.FromRGB(196, 98, 0);
                gbxBottom.BorderColor = Color.FromRGB(196, 98, 0);
            }
        }
    }
    


Applying Theme in building controls.

  • ControlStyleStyleForm ControlStyleStyleFormControlStyleStyleForm
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    using Winbooks.Framework.Styles;
    namespace Winbooks.Documentation.Examples
    {
                                public class ControlStyleStyleForm : ZForm
        {
                                #region Variables
                                protected string curTheme = "";
                                public VioletTheme violetTheme = null;
                                public CyanTheme cyanTheme = null;
                                #endregion
                                #region Constructor
                                public ControlStyleStyleForm()
            {
                                this.Text = "Themes";
                                this.ButtonsStatus = ButtonsFormStatus.Normal;
                                this.CreateThemes();
                                this.CreateControls(this);
            }
                                #endregion
                                #region Methods
                                /// <summary>
                                /// Create themes for this form
                                /// </summary>
                                private void CreateThemes()
            {
                                #region Initiates theme
                                this.violetTheme = new VioletTheme();
                                this.cyanTheme = new CyanTheme();
                                this.curTheme = VioletTheme.Name;
                                //Create a theme based on a collection of  control style
                Themes.Add(new Winbooks.Framework.Styles.Theme(VioletTheme.Name, violetTheme.Styles));
                Themes.Add(new Winbooks.Framework.Styles.Theme(CyanTheme.Name, cyanTheme.Styles));
                                #endregion
            }
                                /// <summary>
                                /// Create controls in the form
                                /// </summary>
                                public void CreateControls(IContainer parent)
            {
                                this.Theme = GetTheme(curTheme);
                                this.FormStyle = GetStyle(this.curTheme, StyleKeys.WFormStyle.ToString());
                                #region Left Controls
                                #endregion
                ControlContainer ccIntro = new ControlContainer(Mode.Under, "ccIntro");
                ccIntro.Parent = parent;
                ccIntro.ControlStyle = GetStyle(this.curTheme, StyleKeys.WControlContainer);
                                 ZLabel lblIntro = new ZLabel(Mode.Under, "lblIntro", "Select a Theme of the form");
                lblIntro.Parent = ccIntro;
                lblIntro.ControlStyle = GetStyle(this.curTheme, StyleKeys.WLabelStyle);
                                 ZGroupBox gbxThemes = new ZGroupBox(Mode.Under | Mode.WidthFixed | Mode.HeightFixed, "gbxThemes", "Themes");
                gbxThemes.Parent = ccIntro;
                gbxThemes.LabelStyle = GroupBoxLabelStyle.CenterBottom;
                gbxThemes.ControlStyle = GetStyle(this.curTheme, StyleKeys.WGroupBox);
                                 ZButton btnVioletTheme = new ZButton(Mode.Under, "btnVioletTheme", "Violete");
                btnVioletTheme.Parent = gbxThemes;
                btnVioletTheme.BackColor = Color.Violet;
                btnVioletTheme.Click += new ZEventHandler(btnVioletTheme_Click);
                                 ZButton btnCyanTheme = new ZButton(Mode.Right, "btnCyanTheme", "Cyan");
                btnCyanTheme.Parent = gbxThemes;
                btnCyanTheme.BackColor = Color.Cyan;
                btnCyanTheme.Click += new ZEventHandler(btnCyanTheme_Click);
                                 ZLabel lblInfo1 = new ZLabel(Mode.Under, "lblInfo1", "Override BorderColor of groupbox to Orange");
                lblInfo1.Parent = ccIntro;
                lblInfo1.ControlStyle = GetStyle(this.curTheme, StyleKeys.WLabelStyle);
                                 ZButton btnFontOverride = new ZButton(Mode.Under | Mode.WidthFixed, "btnFontOverride", "Override theme");
                btnFontOverride.Parent = ccIntro;
                btnFontOverride.Width = 60;
                btnFontOverride.ImageIndex = ImageSixteenShadow.Pencil;
                btnFontOverride.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZGroupBox gbxDemo = new ZGroupBox(Mode.Right, "gbxDemo", "Controls");
                gbxDemo.Parent = parent;
                gbxDemo.ControlStyle = GetStyle(this.curTheme, StyleKeys.WGroupBox);
                                 ZTextBox tbx = new ZTextBox(Mode.Under | Mode.WidthFixed, new Source("tbx"), 120);
                tbx.Parent = gbxDemo;
                tbx.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZButton btnImage = new ZButton(Mode.Right | Mode.Contiguous, "btnImage", "");
                btnImage.Parent = gbxDemo;
                btnImage.ButtonStyle = ButtonStyle.Customized;
                btnImage.ImageIndex = ImageSixteenShadow.UpArrow;
                btnImage.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZButton btnImage1 = new ZButton(Mode.Right | Mode.Contiguous, "btnImage1", "");
                btnImage1.Parent = gbxDemo;
                btnImage1.ButtonStyle = ButtonStyle.Customized;
                btnImage1.ImageIndex = ImageSixteenShadow.DownArrow;
                btnImage1.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZLookUpControl lk = new ZLookUpControl(Mode.Under | Mode.WidthFixed | Mode.RightAlign, new Source("lkControl"), null);
                lk.Parent = gbxDemo;
                lk.ImageIndex = ImageSixteenShadow.Find;
                lk.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZLookUpControl lk1 = new ZLookUpControl(Mode.Under | Mode.WidthFixed, new Source("lk1"), 80);
                lk1.Parent = gbxDemo;
                lk1.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZLabel lblDate = new ZLabel(Mode.Right | Mode.Contiguous, "lblDate", "Date");
                lblDate.Parent = gbxDemo;
                lblDate.ControlStyle = GetStyle(this.curTheme, StyleKeys.WLabelStyle);
                                 ZDatePicker datePicker = new ZDatePicker(Mode.Right | Mode.Contiguous | Mode.WidthFixed | Mode.RightAlign, new Source("datePicker"), 80);
                datePicker.Parent = gbxDemo;
                datePicker.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZGridView grvUser = new ZGridView(Mode.Under | Mode.RightAlign, "grvUser", null, null);
                grvUser.Parent = gbxDemo;
                grvUser.RowHeadersVisible = false;
                grvUser.ColumnHeadersHeight = 25;
                grvUser.ControlStyle = GetStyle(this.curTheme, StyleKeys.WGridViewStyle);
                                //Read column
                                 ZTextBox txtRead = new ZTextBox(null, new Source("Read"), null); //SourceMember is as both control key and Property name of bound data class
                txtRead.ImageIndex = ImageSixteenShadow.Add;
                txtRead.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZGridViewColumn colRead = new ZGridViewColumn("colRead", "Read", txtRead);
                colRead.Style.ImageAlign = ContentAlignment.MiddleCenter;
                colRead.Width = 50;
                colRead.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                //Sex column
                                 ZCheckBox cboSex = new ZCheckBox(null, new Source("Sex"), null);
                cboSex.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZGridViewColumn colSex = new ZGridViewColumn("colSex", "Sex", cboSex);
                colSex.Width = 50;
                colSex.Style.TextAlign = ContentAlignment.MiddleCenter;
                colSex.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                //Name column
                                 ZTextBox txtName = new ZTextBox(null, new Source("Name"), null);
                txtName.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                                 ZGridViewColumn colName = new ZGridViewColumn("colName", "Name", txtName);
                colName.AllowSort = true;
                colName.ControlMode = Mode.WidthResizable;
                colName.Style.TextAlign = ContentAlignment.MiddleLeft;
                colName.ControlStyle = GetStyle(this.curTheme, StyleKeys.WDefaultStyle);
                grvUser.Columns.Add(colRead);
                grvUser.Columns.Add(colSex);
                grvUser.Columns.Add(colName);
                grvUser.QuerySort = "Name ASC";
            }
                                void btnCyanTheme_Click(object sender, ZEventArgs e)
            {
                                this.curTheme = CyanTheme.Name;
                                this.Theme = GetTheme(this.curTheme);
            }
                                void btnVioletTheme_Click(object sender, ZEventArgs e)
            {
                                this.curTheme = VioletTheme.Name;
                                this.Theme = GetTheme(this.curTheme);
            }
                                /// <summary>
                                /// Get style from a theme
                                /// </summary>
                                /// <param name="themeKey"></param>
                                /// <param name="styleKey"></param>
                                /// <returns></returns>
                                public static IBaseStyle GetStyle(string themeKey, string styleKey)
            {
                IBaseStyle style = null;
                                if (!string.IsNullOrEmpty(themeKey))
                {
                                 Winbooks.Framework.Styles.Theme theme = Themes.Get(themeKey);
                                if (theme != null)
                        style = theme.GetByElementKey(styleKey);
                }
                                return style;
            }
                                /// <summary>
                                /// Get theme based on theme key
                                /// </summary>
                                /// <param name="themeKey"></param>
                                /// <returns></returns>
                                public static Winbooks.Framework.Styles.Theme GetTheme(string themeKey)
            {
                                if (!string.IsNullOrEmpty(themeKey))
                                return Themes.Get(themeKey);
                                return null;
            }
                                #endregion
        }
                                #region StyleKeys
                                public class StyleKeys
        {
                                public static string WDefaultStyle = "WDefaultStyle";
                                public static string WFormStyle = "WFormStyle";
                                public static string WLabelStyle = "WLabelStyle";
                                public static string WGridViewStyle = "WGridViewStyle";
                                public static string WControlContainer = "WControlContainer";
                                public static string WGroupBox = "WGroupBox";
        }
                                #endregion
                                #region Violet Theme
                                public class VioletTheme
        {
                                #region Variables
                                public StyleCollection Styles { get; set; }
                                public static string Name = "VioletTheme";
                                #endregion
                                #region Constructor
                                public VioletTheme()
            {
                                this.Styles = new StyleCollection();
                                this.Styles.Add(new VioletDefaultStyle());
                                this.Styles.Add(new VioletFormStyle());
                                this.Styles.Add(new VioletLabelStyle());
                                this.Styles.Add(new VioletGridViewStyle());
                                this.Styles.Add(new VioletControlContainer());
                                this.Styles.Add(new VioletGroupBoxstyle());
            }
                                #endregion
                                #region Style Classes
                                #region DefaultStyle
                                public class VioletDefaultStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WDefaultStyle; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                public Color BackColor
                {
                                get
                    {
                                return Color.Violet;
                    }
                }
                                public Color ForeColor
                {
                                get
                    {
                                return Color.White;
                    }
                }
                                #endregion
            }
                                #endregion
                                #region VioletFormStyle
                                /// <summary>
                                /// Form Style
                                /// </summary>
                                public class VioletFormStyle : IBaseStyle
            {
                                public virtual Color HeaderTopColor { get { return Color.Violet; } }
                                public virtual Color HeaderBottomColor { get { return Color.Violet; } }
                                #region IFormGreenStyle Members
                                public virtual Color ActiveTitleColor { get { return this.TitleForeColor; } }
                                public virtual Color BorderColor { get { return this.HeaderTopColor; } }
                                public virtual Color ButtonLineColor { get { return Color.Violet; } }
                                public virtual Color ButtonMainColor { get { return Color.Violet; } }
                                public virtual Color HeaderLineColor { get { return Color.Violet; } }
                                public virtual Color FooterLineColor { get { return Color.Violet; } }
                                public virtual Color TitleForeColor { get { return Color.White; } }
                                public virtual Color BackColor { get { return Color.Violet; } }
                                #endregion
                                #region IBaseGreenStyle Members
                                public virtual string ElementKey { get { return StyleKeys.WFormStyle.ToString(); } }
                                public virtual bool IsDefault { get { return true; } }
                                #endregion
            }
                                #endregion
                                #region VioletLabelStyle
                                public class VioletLabelStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get
                    {
                                return StyleKeys.WLabelStyle.ToString();
                    }
                }
                                public bool IsDefault
                {
                                get
                    {
                                return true;
                    }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Violet; }
                }
                                public virtual Color ForeColor
                {
                                get { return Color.White; }
                }
            }
                                #endregion
                                #region VioletGridViewStyle
                                public class VioletGridViewStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WGridViewStyle; }
                }
                                public bool IsDefault
                {
                                get { return true; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Violet; }
                }
            }
                                #endregion
                                #region VioletGroupBoxStyle
                                public class VioletGroupBoxstyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WGroupBox; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Violet; }
                }
                                public virtual Color TopHeaderColor
                {
                                get { return Color.Violet; }
                }
                                public virtual Color BottomHeaderColor
                {
                                get { return Color.Violet; }
                }
                                public virtual Color ForeColor
                {
                                get { return Color.White; }
                }
            }
                                #endregion
                                #region VioletControlContainer
                                public class VioletControlContainer : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WControlContainer; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Violet; }
                }
            }
                                #endregion
                                #endregion
        }
                                #endregion
                                #region Cyan Theme
                                public class CyanTheme
        {
                                #region Variable
                                public StyleCollection Styles { get; set; }
                                public static String Name = "CyanTheme";
                                #endregion
                                #region Constructor
                                public CyanTheme()
            {
                Styles = new StyleCollection();
                Styles.Add(new CyanDefaultStyle());
                Styles.Add(new CyanFormStyle());
                Styles.Add(new CyanLabelStyle());
                Styles.Add(new CyanGridViewStyle());
                Styles.Add(new CyanControlContainer());
                Styles.Add(new CyanGroupBoxstyle());
            }
                                #endregion
                                #region Style Classes
                                #region DefaultStyle
                                public class CyanDefaultStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WDefaultStyle; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                public Color BackColor
                {
                                get 
                    {
                                return Color.Cyan;    
                    }
                }
                                public Color ForeColor
                {
                                get
                    {
                                return Color.Black;
                    }
                }
                                #endregion
            }
                                #endregion
                                #region CyanFormStyle
                                /// <summary>
                                /// Form Style
                                /// </summary>
                                public class CyanFormStyle : IBaseStyle
            {
                                public virtual Color HeaderTopColor { get { return Color.Cyan; } }
                                public virtual Color HeaderBottomColor { get { return Color.Cyan; } }
                                #region IFormGreenStyle Members
                                public virtual Color ActiveTitleColor { get { return this.TitleForeColor; } }
                                public virtual Color BorderColor { get { return this.HeaderTopColor; } }
                                public virtual Color ButtonLineColor { get { return Color.Cyan; } }
                                public virtual Color ButtonMainColor { get { return Color.Cyan; } }
                                public virtual Color HeaderLineColor { get { return Color.Cyan; } }
                                public virtual Color FooterLineColor { get { return Color.Cyan; } }
                                public virtual Color TitleForeColor { get { return Color.Black; } }
                                public virtual Color BackColor { get { return Color.Cyan; } }
                                #endregion
                                #region IBaseGreenStyle Members
                                public virtual string ElementKey { get { return StyleKeys.WFormStyle.ToString(); } }
                                public virtual bool IsDefault { get { return true; } }
                                #endregion
            }
                                #endregion
                                #region CyanLabelStyle
                                public class CyanLabelStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WLabelStyle; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Cyan; }
                }
                                public virtual Color ForeColor
                {
                                get { return Color.Black; }
                }
            }
                                #endregion
                                #region CyanGridViewStyle
                                public class CyanGridViewStyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WGridViewStyle; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Cyan; }
                }
            }
                                #endregion
                                #region CyanGroupBoxStyle
                                public class CyanGroupBoxstyle : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WGroupBox; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Cyan; }
                }
                                public virtual Color TopHeaderColor
                {
                                get { return Color.Cyan; }
                }
                                public virtual Color BottomHeaderColor
                {
                                get { return Color.Cyan; }
                }
                                public virtual Color ForeColor
                {
                                get { return Color.Black; }
                }
            }
                                #endregion
                                #region CyanControlContainer
                                public class CyanControlContainer : IBaseStyle
            {
                                #region IBaseStyle Members
                                public string ElementKey
                {
                                get { return StyleKeys.WControlContainer; }
                }
                                public bool IsDefault
                {
                                get { return false; }
                }
                                #endregion
                                public virtual Color BackColor
                {
                                get { return Color.Cyan; }
                }
            }
                                #endregion
                                #endregion
        }
                                #endregion
    }
    


Applying Transalation for multi-language form.

  • TranslationForm TranslationFormTranslationForm
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Winbooks.Framework.Controls;
    using TS = Winbooks.Translation.TranslationServices;
    using Winbooks.Framework.Services;
    namespace Winbooks.Documentation.Examples
    {
                                public class TranslationForm : ZForm
        {
                                #region Constructor
                                public TranslationForm()
            {
                LoadLanguageDefault();
                                this.Text = TS.L(3, 1 /* "Translation Form" */);
                CreateControls(this);
            }
                                #endregion
                                #region Methods
                                /// <summary>
                                /// Load Default Language: English
                                /// </summary>
                                private void LoadLanguageDefault()
            {
                LoadLanguage("en");
            }
                                /// <summary>
                                /// Load a language
                                /// </summary>
                                /// <param name="userLanguage"></param>
                                private void LoadLanguage(string userLanguage)
            {
                                 Winbooks.Translation.TranslationServices.Instance.LoadTranslation(userLanguage);
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(userLanguage);
                SessionService.CurrentSession.UserLanguage = userLanguage;
            }
                                /// <summary>
                                /// Create controls for the form
                                /// </summary>
                                /// <param name="parent">parent of controls</param>
                                private void CreateControls(IContainer parent)
            {
                                 ZLabel lblSelectLanguage = new ZLabel(Mode.Under, "lblSelectLanguage", TS.L(3, 9 /*"Select a language"*/));
                lblSelectLanguage.Parent = parent;
                                 ZComboBox cbxLanguage = new ZComboBox(Mode.Right | Mode.Contiguous | Mode.Fixed, new Source("cbxLanguage"), null);
                cbxLanguage.Parent = parent;
                cbxLanguage.SelectedValueChanged += new ZEventHandler(cbxLanguage_SelectedValueChanged);
                cbxLanguage.Items.Add(new ListItem(TS.L(3, 2 /* "English" */), "en"));
                cbxLanguage.Items.Add(new ListItem(TS.L(3, 3 /* "French" */), "fr"));
                cbxLanguage.Items.Add(new ListItem(TS.L(3, 4 /* "Vietnamese" */), "vi"));
                cbxLanguage.SelectedIndex = 0; //Default language: English
                                 ZGroupBox gbMode = new ZGroupBox(Mode.Under, "gbMode", string.Empty);
                gbMode.Parent = parent;
                                 ZLabel lblMode1 = new ZLabel(Mode.Under, "lblMode1", TS.L(3, 5 /* "Mode 1: TS.L("Welcome every one to Winbooks Help")" */));
                lblMode1.Parent = gbMode;
                                 ZLabel lblValue1 = new ZLabel(Mode.Under, "lblValue1", TS.L(3, 10));
                lblValue1.Parent = gbMode;
                lblValue1.ForeColor = Color.Blue;
                lblValue1.Font = new Font("Arial", 9, FontStyle.Italic);
                                 ZLabel lblMode2 = new ZLabel(Mode.Under, "lblMode2", TS.L(3, 6/* "Mode 2: TS.L("Welcome {0} to Winbooks Help.", new object[] {"Bill Gates"})" */));
                lblMode2.Parent = gbMode;
                                 ZLabel lblValue2 = new ZLabel(Mode.Under, "lblValue2", TS.L(3, 11, new object[] { "Bill Gates" }));
                lblValue2.ForeColor = Color.Blue;
                lblValue2.Font = new Font("Arial", 9, FontStyle.Italic);
                                 ZLabel lblMode3 = new ZLabel(Mode.Under, "lblMode3", TS.L(3, 7 /* "Mode 3: TS.L("Welcome {0} to Winbooks Help", false, new object[]{"Bill Gates"}) + ". Thanks for comming!" */));
                lblMode3.Parent = gbMode;
                                 ZLabel lblValue3 = new ZLabel(Mode.Under, "lblValue3", TS.L(3, 11, false, new object[] { "Bill Gates" }) + TS.L(3, 12));
                lblValue3.Parent = gbMode;
                lblValue3.ForeColor = Color.Blue;
                lblValue3.Font = new Font("Arial", 9, FontStyle.Italic);
            }
                                void cbxLanguage_SelectedValueChanged(object sender, ZEventArgs e)
            {
                LoadLanguage((sender as ZComboBox).SelectedValue.ToString());
            }
                                #endregion
        }
    }
    


Top