Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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:

CreateTabbedGroup_ex

using DevExpress.XtraLayout;

LayoutControl lc = new LayoutControl();
lc.Dock = System.Windows.Forms.DockStyle.Fill;
this.Controls.Add(lc);
// Lock the layout control to prevent excessive updates.
lc.BeginUpdate();
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.
    lc.EndUpdate();
}