Back to Devexpress

TreeList.GetDataRecordByNode(TreeListNode) Method

windowsforms-devexpress-dot-xtratreelist-dot-treelist-dot-getdatarecordbynode-x28-devexpress-dot-xtratreelist-dot-nodes-dot-treelistnode-x29.md

latest7.3 KB
Original Source

TreeList.GetDataRecordByNode(TreeListNode) Method

Returns a data row associated with the node specified.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
public virtual object GetDataRecordByNode(
    TreeListNode node
)
vb
Public Overridable Function GetDataRecordByNode(
    node As TreeListNode
) As Object

Parameters

NameTypeDescription
nodeTreeListNode

The TreeListNode object representing the node whose associated data row is to be obtained.

|

Returns

TypeDescription
Object

A data row associated with the node specified. null ( Nothing in Visual Basic) if the node is not found.

|

Remarks

If the Tree List is bound to a data source, the GetDataRecordByNode method returns the data row associated with the specified node. When working in unbound mode, an array of cell values that reside within the specified node is returned.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetDataRecordByNode(TreeListNode) 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-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.cs#L54

csharp
private void Tree_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e) {
    var row = tree.GetDataRecordByNode(e.Node) as DashboardFlatDataSourceRow;
    e.DisplayText = flatData.GetDisplayText(e.Column.FieldName, row);

winforms-richeditcontrol-common-api/CS/RichEditAPISample/Form1.cs#L463

csharp
void OnNewExampleSelected(object sender, FocusedNodeChangedEventArgs e) {
    CodeExample newExample = (sender as TreeList).GetDataRecordByNode(e.Node) as CodeExample;
    CodeExample oldExample = (sender as TreeList).GetDataRecordByNode(e.OldNode) as CodeExample;

word-document-api-examples/CS/Form1.cs#L85

csharp
treeList1.FocusedNode = treeList1.MoveFirst().FirstNode;
RichEditExample example = treeList1.GetDataRecordByNode(treeList1.FocusedNode) as RichEditExample;
codeEditor.ShowExample(example);

winforms-tokenedit-dropdown-with-treelist/CS/TokenEditTest/CustomTokenEditDropDownControl.cs#L78

csharp
}
object GetSelectedDataItem() { return this.selNode != null ? TreeList.GetDataRecordByNode(this.selNode) : null; }
void OnTreeListVirtualTreeGetChildNodes(object sender, VirtualTreeGetChildNodesInfo e) {

excel-export-api-examples/CS/XLExportExamples/Form1.cs#L144

csharp
{
    SpreadsheetExample example = treeList1.GetDataRecordByNode(treeList1.FocusedNode) as SpreadsheetExample;
    if (example == null)

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

vb
Private Sub Tree_CustomColumnDisplayText(ByVal sender As Object, ByVal e As CustomColumnDisplayTextEventArgs)
    Dim row = TryCast(tree.GetDataRecordByNode(e.Node), DashboardFlatDataSourceRow)
    e.DisplayText = flatData.GetDisplayText(e.Column.FieldName, row)

winforms-richeditcontrol-common-api/VB/RichEditAPISample/Form1.vb#L459

vb
Private Sub OnNewExampleSelected(ByVal sender As Object, ByVal e As FocusedNodeChangedEventArgs)
    Dim newExample As CodeExample = TryCast((TryCast(sender, TreeList)).GetDataRecordByNode(e.Node), CodeExample)
    Dim oldExample As CodeExample = TryCast((TryCast(sender, TreeList)).GetDataRecordByNode(e.OldNode), CodeExample)

word-document-api-examples/VB/Form1.vb#L81

vb
If treeList1.Nodes.Count > 0 Then treeList1.FocusedNode = treeList1.MoveFirst().FirstNode
Dim example As RichEditExample = TryCast(treeList1.GetDataRecordByNode(treeList1.FocusedNode), RichEditExample)
codeEditor.ShowExample(example)

winforms-tokenedit-dropdown-with-treelist/VB/TokenEditTest/CustomTokenEditDropDownControl.vb#L87

vb
Private Function GetSelectedDataItem() As Object
    Return If(Me.selNode IsNot Nothing, TreeList.GetDataRecordByNode(Me.selNode), Nothing)
End Function

excel-export-api-examples/VB/XLExportExamples/Form1.vb#L143

vb
Private Sub RunExample(ByVal filePath As String, ByVal documentFormat As XlDocumentFormat)
   Dim example As SpreadsheetExample = TryCast(treeList1.GetDataRecordByNode(treeList1.FocusedNode), SpreadsheetExample)
   If example Is Nothing Then

See Also

Id

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace