Back to Devexpress

TreeListView.CustomColumnDisplayText Event

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-75084561.md

latest5.7 KB
Original Source

TreeListView.CustomColumnDisplayText Event

Allows you to customize a data cell‘s display text.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event TreeListCustomColumnDisplayTextEventHandler CustomColumnDisplayText
vb
Public Event CustomColumnDisplayText As TreeListCustomColumnDisplayTextEventHandler

Event Data

The CustomColumnDisplayText event's data class is TreeListCustomColumnDisplayTextEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets the column which owns the processed cell.
DisplayTextGets or sets the display text for the cell currently being processed.
NodeGets the node which owns the processed cell.
ShowAsNullTextSpecifies whether text corresponding to a null value appears faded.
ValueGets the processed cell’s value.

Remarks

The CustomColumnDisplayText event occurs for bound and unbound columns. The printed GridControl also displays customized text.

If you want to maintain a clean MVVM pattern and customize a data cell’s display text in a View Model, create a command and bind it to the CustomColumnDisplayTextCommand property.

The TreeListCustomColumnDisplayTextEventArgs.DisplayText property contains a cell’s display text. To customize the display text, assign a string value to this property.

xaml
<dxg:TreeListColumn FieldName="Value"/>
csharp
void treeList_CustomColumnDisplayText(object sender, TreeListCustomColumnDisplayTextEventArgs e) {
    if (e.Column.FieldName == "Value")
        e.DisplayText = string.Format("{0:n2}", e.Value);
}
vb
Private Sub grid_CustomColumnDisplayText(ByVal sender As Object, ByVal e As TreeListCustomColumnDisplayTextEventArgs)
    If e.Column.FieldName = "Value" Then e.DisplayText = String.Format("{0:n2}", e.Value)
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomColumnDisplayText event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/MainWindow.xaml#L52

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/MainWindow.xaml#L52

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

wpf-richedit-document-api/CS/DXRichEditControlAPISample/MainWindow.xaml#L57

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

See Also

Format Cell Values

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace