Back to Devexpress

TreeListNode.SetValue(Object, Object) Method

windowsforms-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-dot-setvalue-x28-system-dot-object-system-dot-object-x29.md

latest4.9 KB
Original Source

TreeListNode.SetValue(Object, Object) Method

Sets the value for a specific column.

Namespace : DevExpress.XtraTreeList.Nodes

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
public virtual void SetValue(
    object columnID,
    object val
)
vb
Public Overridable Sub SetValue(
    columnID As Object,
    val As Object
)

Parameters

NameTypeDescription
columnIDObject

An object that identifies a column (a TreeListColumn object, field name, column’s absolute index or corresponding DataColumn object).

| | val | Object |

The value to set for a specific column in the current node.

|

Remarks

The following objects and values can be passed as column identifiers:

Example

The next example demonstrates how to access a focused node value in the column which is identified by the TreeListColumn.AbsoluteIndex property set to 0.

Two ways are provided to perform this operation: via the TreeListNode.Item property and TreeListNode.SetValue method.

csharp
//first method
treeList1.FocusedNode.SetValue(0, "new value");
//second method
treeList1.FocusedNode[0] = "new value";
vb
'first method
TreeList1.FocusedNode.SetValue(0, "new value")
'second method
TreeList1.FocusedNode(0) = "new value"

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetValue(Object, Object) method.

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-treelist-sync-position-of-nodes-with-data-records/CS/Q351285/Form1.cs#L61

csharp
for(var i = 0; i < nodes.Count; i++) {
    nodes[i].SetValue(colSort, i);
}

winforms-treelist-customize-node-menu/CS/Form1.cs#L32

csharp
TreeListNode newNode = treeList1.AppendNode(null, treeList1.FocusedNode);
newNode.SetValue(0, "New Node");
treeList1.OptionsBehavior.Editable = !treeList1.OptionsBehavior.Editable;

winforms-treelist-sync-position-of-nodes-with-data-records/VB/Q351285/Form1.vb#L74

vb
For i = 0 To nodes.Count - 1
    nodes(i).SetValue(colSort, i)
Next

winforms-treelist-customize-node-menu/VB/Form1.vb#L34

vb
Dim newNode As TreeListNode = treeList1.AppendNode(Nothing, treeList1.FocusedNode)
newNode.SetValue(0, "New Node")
treeList1.OptionsBehavior.Editable = Not treeList1.OptionsBehavior.Editable

See Also

TreeListNode Class

TreeListNode Members

DevExpress.XtraTreeList.Nodes Namespace