Back to Devexpress

TreeListColumn.FieldName Property

windowsforms-devexpress-dot-xtratreelist-dot-columns-dot-treelistcolumn-244287cb.md

latest8.1 KB
Original Source

TreeListColumn.FieldName Property

Gets or sets the field name assigned to the current column from a datasource.

Namespace : DevExpress.XtraTreeList.Columns

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
[DefaultValue("")]
[XtraSerializableProperty]
public string FieldName { get; set; }
vb
<DefaultValue("")>
<XtraSerializableProperty>
Public Property FieldName As String

Property Value

TypeDefaultDescription
StringString.Empty

A String value that specifies the name of a data field.

|

Remarks

Use this property to change the field name assigned to the current column from the datasource. If this property is changed at runtime, the column caption is not modified, but the column contents change. In order to update the column caption, set the TreeListColumn.Caption property to the appropriate value.

The FieldName property value can be used as a column identifier, as for example, in the TreeListNode.Item property, TreeListNode.GetValue and other methods.

There must be a case match between strings assigned to the FieldName properties, and the names of the columns in the underlying data source.

Example

The following example demonstrates how to add and adjust a new column bound to the “Checked” field. The column is bound to the field using the TreeListColumn.FieldName property. The sample code changes the caption of the column and its visible index via the TreeListColumn.Caption and TreeListColumn.VisibleIndex properties.

csharp
TreeListColumn column = treeList1.Columns.Add();
column.FieldName = "Checked";   
column.Caption = "Check-It";
column.VisibleIndex = treeList1.Columns.Count - 1;
vb
TreeListColumn Column = TreeList1.Columns.Add()
Column.FieldName = "Checked"
Column.Caption = "Check-It"
Column.VisibleIndex = TreeList1.Columns.Count - 1

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

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.

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.cs#L55

csharp
var row = tree.GetDataRecordByNode(e.Node) as DashboardFlatDataSourceRow;
    e.DisplayText = flatData.GetDisplayText(e.Column.FieldName, row);
}

winforms-treelist-create-file-manager-drag-drop-files-folders/CS/FileList/FileListHelper.cs#L47

csharp
this.treeListColumn1.Caption = "FullName";
this.treeListColumn1.FieldName = "FullName";

xaf-win-enable-inplace-editing-in-tree-list-view/CS/EFCore/TreeListInplaceEF/TreeListInplaceEF.Win/Controllers/TreeListAppearanceControllerEx.cs#L19

csharp
if (node == null) return;
    this.OnCustomizeAppearance(new CustomizeAppearanceEventArgs(tl.FocusedColumn.FieldName, "ViewItem", new GridViewCancelEventArgsAppearanceAdapter(null, e), node.Object, null));
}

winforms-treelist-unbound-columns/CS/TreeList_UnboundDataViaEvent/Form1.cs#L30

csharp
unbColumnMarchChange.OptionsColumn.AllowEdit = false;
unbColumnMarchChange.FieldName = "ChangeFromPrevYear";
unbColumnMarchChange.Caption = "Change from Previous Year";

xaf-win-gantt-control/CS/XPO/GanttSolutionXPO/GanttSolutionXPO.Win/Editors/CustomGanttEditor.cs#L69

csharp
ganttColumn.Caption = column.Caption;
ganttColumn.FieldName = column.PropertyName;
ganttColumn.Name = column.PropertyName + "Column";

winforms-treelist-create-file-manager-drag-drop-files-folders/VB/FileList/FileListHelper.vb#L46

vb
treeListColumn1.Caption = "FullName"
treeListColumn1.FieldName = "FullName"
treeListColumn2.Caption = "Name"

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.vb#L61

vb
Dim row = TryCast(tree.GetDataRecordByNode(e.Node), DashboardFlatDataSourceRow)
    e.DisplayText = flatData.GetDisplayText(e.Column.FieldName, row)
End Sub

winforms-treelist-unbound-columns/VB/TreeList_UnboundDataViaEvent/Form1.vb#L25

vb
unbColumnMarchChange.OptionsColumn.AllowEdit = False
unbColumnMarchChange.FieldName = "ChangeFromPrevYear"
unbColumnMarchChange.Caption = "Change from Previous Year"

winforms-treelist-expression-editor-xpview/VB/E1887/Form1.vb#L56

vb
If column Is Nothing Then Return String.Empty
    Return If(String.IsNullOrEmpty(column.Caption), column.FieldName, column.Caption)
End Get

winforms-treelist-virtual-mode/VB/ExampleMainForm.vb#L20

vb
Dim newColumnDescription As TreeListColumn = MyTtreeList.Columns.Add()
newColumnDescription.FieldName = "Description"
newColumnDescription.VisibleIndex = 0

See Also

TreeListColumn Class

TreeListColumn Members

DevExpress.XtraTreeList.Columns Namespace