Skip to main content

How to: Create a tabbed group in code

  • 3 minutes to read

The following example shows how to create a tabbed group that contains two pages. The first page will display a group with a layout item that contains a PictureEdit editor.

A tabbed group is created using the LayoutControlGroup.AddTabbedGroup method of the root group. Tabs are added via the TabbedGroup.AddTabPage method.

The following image shows the result:


using DevExpress.XtraLayout;

LayoutControl lc = new LayoutControl();
lc.Dock = System.Windows.Forms.DockStyle.Fill;
// Lock the layout control to prevent excessive updates.
try {
    // Create a tabbed group within the root group.
    TabbedControlGroup tabbedGroup = lc.Root.AddTabbedGroup();
    tabbedGroup.Name = "TabbedGroup";
    // Add the Photo group as a tab.
    LayoutControlGroup groupPhoto = tabbedGroup.AddTabPage() as LayoutControlGroup;
    groupPhoto.Name = "lgPhoto";
    groupPhoto.Text = "Photo";
    // Add a new layout item to the group to display an image.
    LayoutControlItem liPhoto = groupPhoto.AddItem();
    liPhoto.Name = "liPhoto";
    liPhoto.Control = new DevExpress.XtraEditors.PictureEdit() { Name = "pePhoto" };
    // Hide the item's text region.
    liPhoto.TextVisible = false;
    // Add the Notes group as a tab.
    LayoutControlGroup groupNotes = tabbedGroup.AddTabPage() as LayoutControlGroup;
    groupNotes.Name = "lgNotes";
    groupNotes.Text = "Notes";
    // Add a new layout item to the group to display a memo editor.
    LayoutControlItem liNotes = groupNotes.AddItem();
    liNotes.Name = "liNotes";
    liNotes.Control = new DevExpress.XtraEditors.MemoEdit() { Name = "meNotes" }; ;
    // Hide the item's text region.
    liNotes.TextVisible = false;

    // Make the first tab page active.
    tabbedGroup.SelectedTabPage = groupPhoto;
finally {
    // Unlock and update the layout control.