wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-75084561.md
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
public event TreeListCustomColumnDisplayTextEventHandler CustomColumnDisplayText
Public Event CustomColumnDisplayText As TreeListCustomColumnDisplayTextEventHandler
The CustomColumnDisplayText event's data class is TreeListCustomColumnDisplayTextEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Column | Gets the column which owns the processed cell. |
| DisplayText | Gets or sets the display text for the cell currently being processed. |
| Node | Gets the node which owns the processed cell. |
| ShowAsNullText | Specifies whether text corresponding to a null value appears faded. |
| Value | Gets the processed cell’s value. |
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.
<dxg:TreeListColumn FieldName="Value"/>
void treeList_CustomColumnDisplayText(object sender, TreeListCustomColumnDisplayTextEventArgs e) {
if (e.Column.FieldName == "Value")
e.DisplayText = string.Format("{0:n2}", e.Value);
}
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
<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
<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
<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