Preview Sections
- 2 minutes to read
Preview sections are non-editable regions that allow nodes to display large memo text or custom data. They are displayed under nodes’ data cells across all columns.
#Contents - Displaying Data from a Single Field
To display preview sections, do the following:
- Set the TreeListOptionsView.ShowPreview property to true.
- Set the TreeList.PreviewFieldName property to a field that automatically provides data for preview sections.
#Custom Contents
Set the TreeListOptionsView.ShowPreview property to true, and then handle one of the following events to provide custom contents for preview sections:
- TreeList.GetPreviewText - Allows you to provide custom text for preview sections.
- TreeList.CustomDrawNodePreview - Allows you to manually paint text and graphics elements in preview sections.
#Example
The sample code below handles the TreeList.GetPreviewText event to display the Location and Phone field values in preview sections.
The following image shows the results.
using DevExpress.XtraTreeList;
treeList1.OptionsView.ShowPreview = true;
private void treeList1_GetPreviewText(object sender, GetPreviewTextEventArgs e) {
e.PreviewText = "Office Location: " + e.Node["Location"].ToString() + "; Phone: " +
e.Node["Phone"].ToString();
}
#Height
Use the following members to specify preview section height:
TreeList.PreviewLineCount - Gets or sets the number of text lines in preview sections.
This property is set to 2 in the following image:
- TreeListOptionsView.AutoCalcPreviewLineCount - Gets or sets whether the number of text lines in preview sections is calculated automatically depending on their contents.
- TreeList.MeasurePreviewHeight - This event allows you to specify individual preview sections’ height in pixels.
#Appearance
- TreeListAppearanceCollection.Preview - Gets the appearance settings used to paint preview sections.
- TreeList.CustomDrawNodePreview - Allows you to customize the appearance settings while custom painting preview sections.
#Printing API
- TreeListOptionsPrint.PrintPreview - Gets or sets whether preview sections are printed.
- TreeList.GetPrintPreviewText - Enables you to display custom text in preview sections when the control is printed.
- TreeListPrintAppearanceCollection.Preview - Gets the appearance settings used to paint the preview sections when the Tree List is printed.