windowsforms-18021-controls-and-libraries-tree-list-examples-data-representation-how-to-create-a-band-layout-in-code.md
The following code demonstrates how to create a band layout that contains three top-level bands and two nested bands, and associate these bands with columns.
Bands residing at the top hierarchy level are exposed by the TreeList.Bands collection. Each band within the collection exposes the TreeListBand.Bands property that provides access to the band’s child bands. In this example, three top-level bands ( Main , Details and Picture ) are created and added to the TreeList’s Bands collection. After that, two bands ( Absolute Values and Related To Earth Values ) are added to the Bands collection of the Details band.
To assign columns to bands, each column is added to the TreeListBand.Columns collection of an appropriate band.
The following image demonstrates the result of this code.
using DevExpress.XtraTreeList.Columns;
//...
//Clear the TreeList's band collection
treeList1.Bands.Clear();
//Make the band panel visible
treeList1.OptionsView.ShowBandsMode = DefaultBoolean.True;
//Enable the HTML formatting feature
treeList1.OptionsView.AllowHtmlDrawHeaders = true;
//Enable columns to be arranged in multiple rows
treeList1.OptionsView.AllowBandColumnsMultiRow = true;
//Disable the node auto height mode
treeList1.OptionsBehavior.AutoNodeHeight = false;
//Create the band layout
TreeListBand bandMain = treeList1.Bands.Add();
bandMain.Caption = "<b>Main</b>";
TreeListBand bandDetails = treeList1.Bands.Add();
bandDetails.Caption = "<b>Details</b>";
TreeListBand bandPicture = treeList1.Bands.Add();
bandPicture.Caption = "<b>Picture</b>";
TreeListBand bandAbsoluteValues = bandDetails.Bands.Add();
bandAbsoluteValues.Caption = "Absolute Values";
TreeListBand bandRelatedValues = bandDetails.Bands.Add();
bandRelatedValues.Caption = "Related To Earth Values";
//Assign columns to bands
bandMain.Columns.Add(colName);
bandMain.Columns.Add(colTypeOfObject);
bandAbsoluteValues.Columns.Add(colAbsoluteMeanRadius);
bandAbsoluteValues.Columns.Add(colAbsoluteVolume);
bandAbsoluteValues.Columns.Add(colAbsoluteMass);
bandRelatedValues.Columns.Add(colRelatedMeanRadius);
bandRelatedValues.Columns.Add(colRelatedVolume);
bandRelatedValues.Columns.Add(colRelatedMass);
bandPicture.Columns.Add(colIcon);
//Set the vertical position of column headers
colTypeOfObject.RowIndex = 1;
colAbsoluteMass.RowIndex = 1;
colRelatedMass.RowIndex = 1;
// Make columns visible (if they are hidden)
colName.Visible = true;
colTypeOfObject.Visible = true;
colAbsoluteMeanRadius.Visible = true;
colAbsoluteVolume.Visible = true;
colAbsoluteMass.Visible = true;
colRelatedMeanRadius.Visible = true;
colRelatedVolume.Visible = true;
colRelatedMass.Visible = true;
colIcon.Visible = true;
Imports DevExpress.XtraTreeList.Columns
'...
'Clear the Tree List band collection
treeList1.Bands.Clear()
'Make the band panel visible
treeList1.OptionsView.ShowBandsMode = DefaultBoolean.True
'Enable the HTML formatting feature
treeList1.OptionsView.AllowHtmlDrawHeaders = True
'Enable columns to be arranged in multiple rows
treeList1.OptionsView.AllowBandColumnsMultiRow = True
'Disable the node auto height mode
treeList1.OptionsBehavior.AutoNodeHeight = False
'Create the band layout
Dim bandMain As TreeListBand = treeList1.Bands.Add()
bandMain.Caption = "<b>Main</b>"
Dim bandDetails As TreeListBand = treeList1.Bands.Add()
bandDetails.Caption = "<b>Details</b>"
Dim bandPicture As TreeListBand = treeList1.Bands.Add()
bandPicture.Caption = "<b>Picture</b>"
Dim bandAbsoluteValues As TreeListBand = bandDetails.Bands.Add()
bandAbsoluteValues.Caption = "Absolute Values"
Dim bandRelatedValues As TreeListBand = bandDetails.Bands.Add()
bandRelatedValues.Caption = "Related To Earth Values"
'Assign columns to bands
bandMain.Columns.Add(colName)
bandMain.Columns.Add(colTypeOfObject)
bandAbsoluteValues.Columns.Add(colAbsoluteMeanRadius)
bandAbsoluteValues.Columns.Add(colAbsoluteVolume)
bandAbsoluteValues.Columns.Add(colAbsoluteMass)
bandRelatedValues.Columns.Add(colRelatedMeanRadius)
bandRelatedValues.Columns.Add(colRelatedVolume)
bandRelatedValues.Columns.Add(colRelatedMass)
bandPicture.Columns.Add(colIcon)
'Set the vertical position of column headers
colTypeOfObject.RowIndex = 1
colAbsoluteMass.RowIndex = 1
colRelatedMass.RowIndex = 1
' Make columns visible (if they are hidden)
colName.Visible = True
colTypeOfObject.Visible = True
colAbsoluteMeanRadius.Visible = True
colAbsoluteVolume.Visible = True
colAbsoluteMass.Visible = True
colRelatedMeanRadius.Visible = True
colRelatedVolume.Visible = True
colRelatedMass.Visible = True
colIcon.Visible = True