HypernovaDesktop Components · docs
Binarymission
WinForms › Tree List View › BinaryTreeListViewNode

BinaryTreeListViewNode

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.TreeControls

A node of a BinaryTreeListView: one row of the grid, with its own child nodes, which the control shows indented beneath it when it is open.

public class BinaryTreeListViewNode : DataGridViewRow

Inherits from / implements: DataGridViewRow

Remarks

A node is a DataGridViewRow, so its values are in Cells, one per column, and its look in DefaultCellStyle and Height. Keep the object a row stands for in Tag.

Creating nodes

Nodes are usually created by the collections: tree.Nodes.Add(values) for a top-level node and node.Nodes.Add(values) for a child, each taking one value per column and returning the new node. A node made with the constructor is added with BinaryTreeListViewNodesCollection.Add(). The tree builds the rows; never add a node to the grid's own rows.

Open and closed

A node starts closed. Expand() and Collapse() open and close it, raising the control's expanding and collapsing events; while it is closed its descendants are not in the grid at all.

Two indexes

Index is the node's position among its siblings, and stays the same however the tree is opened and closed. NodeIndex is its row in the grid as shown now – the index the grid's own events and methods use – and is -1 while the node is not on show.

Examples

// Columns: Name (the tree column), Size, Modified.
BinaryTreeListViewNode docs = files.Nodes.Add("Documents", "", new DateTime(2026, 9, 30));
BinaryTreeListViewNode invoices = docs.Nodes.Add("Invoices", "", new DateTime(2026, 10, 2));
invoices.Nodes.Add("INV-2026-0412.pdf", "84 KB", new DateTime(2026, 10, 1));
invoices.Nodes.Add("INV-2026-0413.pdf", "79 KB", new DateTime(2026, 10, 2));

docs.Expand();
invoices.Expand();

// Walk up from a node to build its path; the hidden root above the top level has no parent.
BinaryTreeListViewNode node = invoices.Nodes[1];
string path = (string)node.Cells[0].Value;
for (BinaryTreeListViewNode parent = node.ParentNode; parent.ParentNode != null; parent = parent.ParentNode)
    path = parent.Cells[0].Value + "\\" + path;    // Documents\Invoices\INV-2026-0413.pdf

See also

Members at a glance

Constructors
BinaryTreeListViewNodeCreates a closed node with no cells, no children and no parent.
Properties
BinaryTreeListViewCellInfoGets or sets the image settings of this node's tree cell, as one object.
CellInfoCheckStatusGets or sets whether the node shows a check box or a radio button, and whether it is ticked.
CellsGets the node's cells, one per column of the control.
CollapseImageGets or sets the image drawn as this node's collapse glyph while it is open.
ExpandImageGets or sets the image drawn as this node's expand glyph while it is closed.
HasChildrenGets whether the node has any child nodes.
ImageGets or sets the image drawn beside this node's text.
IndexGets the node's position among its siblings.
IsFirstSiblingGets whether the node is the first child of its parent (or the first top-level node).
IsLastSiblingGets whether the node is the last child of its parent (or the last top-level node).
NodeIndexGets the node's row in the grid as it is shown now.
NodesGets the node's children.
ParentNodeGets the node this node is a child of.
ShowNodeImageGets or sets whether the node shows its image.
Methods
CloneCreates a copy of this node's row for the same control, as Clone does.
CloneWithCellsDataCreates a copy of this node with its cell values, ready to add to a tree.
CollapseCloses the node, taking its descendants off the grid.
CollapseCloses the node and, if asked, every node beneath it.
CreateCellsInstanceCreates the node's cell collection, and watches it so that the node finds its cell in the tree column as the cells are added.
ExpandOpens the node, showing its children.
ExpandOpens the node and, if asked, every node beneath it.
ToStringReturns the node's cell values as one string, each followed by a space.

Constructors

BinaryTreeListViewNode

public BinaryTreeListViewNode()

Creates a closed node with no cells, no children and no parent.

Remarks

Add it to a tree with BinaryTreeListViewNodesCollection.Add(); it takes its cells from the control's columns then. Calling Expand() before adding it makes it open as soon as it is shown.

Properties

BinaryTreeListViewCellInfo

public BinaryTreeListViewCellInfo BinaryTreeListViewCellInfo

Gets or sets the image settings of this node's tree cell, as one object.

Value
The BinaryTreeListViewCellInfo last set through this property, or null, the default.
Remarks

Setting it gives the node the info's BinaryTreeListViewCellInfo.Image and BinaryTreeListViewCellInfo.ShowImage, and repaints the control. The text shown in the cell is the cell's value, not the info's BinaryTreeListViewCellInfo.Text; change Cells to change it.

Set it once the node is in a tree; a node that is not throws a NullReferenceException.

See also

CellInfoCheckStatus

public CellInfoCheckStatus CellInfoCheckStatus

Gets or sets whether the node shows a check box or a radio button, and whether it is ticked.

Value
CellInfoCheckStatus.None by default: no check box, and the node's image is shown.
Remarks

Check boxes and radio buttons are drawn only on nodes that have no children, in place of the image. The user changes them by clicking: a check box toggles; a radio button is selected and its siblings' radio buttons are cleared (a radio button with no siblings toggles). Read this property to find out what the user chose.

Setting it does not repaint the node; call DataGridView.InvalidateRow with NodeIndex if the node is on show. BinaryTreeListView.SetUpNodeControlType sets it on every node at once.

Example
// Tick a permission and show the change.
BinaryTreeListViewNode canExport = permissions.Nodes[2].Nodes[0];
canExport.CellInfoCheckStatus = CellInfoCheckStatus.CheckBoxCheckedNormal;
if (canExport.NodeIndex >= 0)
    permissions.InvalidateRow(canExport.NodeIndex);
See also

Cells

public new DataGridViewCellCollection Cells

Gets the node's cells, one per column of the control.

Value
The cells, in column order. For a node that has been added to a tree but is not on show, they are created from the control's columns when first read. null for a node that has not been added to a tree.
Example
BinaryTreeListViewNode node = plan.CurrentNode;
node.Cells["Owner"].Value = "Tom Hughes";
decimal done = Convert.ToDecimal(node.Cells["Done"].Value);

CollapseImage

public Image CollapseImage

Gets or sets the image drawn as this node's collapse glyph while it is open.

Value
null, the default, to use the control's BinaryTreeListView.CollapseImage.
See also

ExpandImage

public Image ExpandImage

Gets or sets the image drawn as this node's expand glyph while it is closed.

Value
null, the default, to use the control's BinaryTreeListView.ExpandImage.
Remarks

A glyph image is used only when an expand image and a collapse image are both available – this node's or the control's; otherwise the system glyph is drawn. It is drawn 10 by 10 logical pixels.

See also

HasChildren

public bool HasChildren

Gets whether the node has any child nodes.

Value
true when Nodes holds at least one node, whether or not this node is open.

Image

public Image Image

Gets or sets the image drawn beside this node's text.

Value
When read: the control's BinaryTreeListView.NodeImage if that is set, otherwise the image set on this node, or null.
Remarks

An image set here is the one drawn for this node, in preference to the control's BinaryTreeListView.NodeImage. It is drawn at its own pixel size, between the expand glyph and the text, unless the node has a check box or radio button or ShowNodeImage is off.

Set it once the node is in a tree and its tree cell has a value; reading or setting it on a node that is not in a tree throws a NullReferenceException.

Example
BinaryTreeListViewNode report = folder.Nodes.Add("Q3 report.xlsx", "212 KB", DateTime.Today);
report.Image = SystemHelper.GetFileIcon("Q3 report.xlsx", SystemHelper.EnumIconSize.Small, false).ToBitmap();
See also

Index

public new int Index

Gets the node's position among its siblings.

Value
The zero-based index of the node in its parent's Nodes, or in the control's top-level nodes.
Exceptions
System.NullReferenceException
The node is not in a collection.
Remarks

It does not depend on which nodes are open. For the node's row in the grid, use NodeIndex.

See also

IsFirstSibling

public bool IsFirstSibling

Gets whether the node is the first child of its parent (or the first top-level node).

Value
true when Index is 0.
Exceptions
System.NullReferenceException
The node is not in a collection.

IsLastSibling

public bool IsLastSibling

Gets whether the node is the last child of its parent (or the last top-level node).

Value
true for the last of its siblings, and for a node that has no parent.

NodeIndex

public int NodeIndex

Gets the node's row in the grid as it is shown now.

Value
The zero-based row index, the same index the grid's own events and methods use; -1 while the node is not on show – inside a closed node, or not yet added to a tree.
Remarks

It changes as nodes above it open, close and are sorted. For the node's place among its siblings, which does not, use Index.

See also

Nodes

public BinaryTreeListViewNodesCollection Nodes

Gets the node's children.

Value
The node's child collection, created the first time it is read; never null.
Remarks

Add children with BinaryTreeListViewNodesCollection.Add(), one value per column. A child is on show while this node is open and on show itself.

See also

ParentNode

public BinaryTreeListViewNode ParentNode

Gets the node this node is a child of.

Value
The parent node; null for a node that has not been added to a tree. For a top-level node it is the control's hidden root node, which is never shown and has no parent of its own.
Remarks

To tell whether a node is at the top level, test tree.Nodes.Contains(node).

ShowNodeImage

public bool ShowNodeImage

Gets or sets whether the node shows its image.

Value
true by default.
Remarks

Setting it repaints the node if it is on show. Set it once the node is in a tree and its tree cell has a value; otherwise it throws a NullReferenceException.

See also

Methods

Clone

public override object Clone()

Creates a copy of this node's row for the same control, as Clone does.

Returns

A new BinaryTreeListViewNode, not in any tree, with no children.

Remarks

For a copy that carries the cell values, check state and glyph images, use CloneWithCellsData.

CloneWithCellsData

public BinaryTreeListViewNode CloneWithCellsData()

Creates a copy of this node with its cell values, ready to add to a tree.

Returns

A new, closed BinaryTreeListViewNode with the same cell values, CellInfoCheckStatus, ExpandImage, CollapseImage and BinaryTreeListViewCellInfo. It has no children and is not in any tree.

Remarks

The children are not copied; copy them one by one if the whole branch is wanted. An image set through Image is not copied; one set through BinaryTreeListViewCellInfo is.

Example
// Duplicate a task under the same parent.
BinaryTreeListViewNode copy = task.CloneWithCellsData();
task.ParentNode.Nodes.Add(copy);
copy.Cells[0].Value = task.Cells[0].Value + " (copy)";

Collapse

public bool Collapse()

Closes the node, taking its descendants off the grid.

Returns

true when the node was closed; false when it was already closed or a BinaryTreeListView.BinaryTreeListViewNodeCollapsing handler kept it open.

Exceptions
System.NullReferenceException
The node is not in a tree.
Remarks

Its children keep their own open state for when it is opened again.

See also

Collapse

public bool Collapse(bool performDeepCollapse)

Closes the node and, if asked, every node beneath it.

Parameters
performDeepCollapse
true to close every descendant as well, so that the branch reopens one level at a time.
Returns

Always true.

Exceptions
System.NullReferenceException
The node is not in a tree.
See also

CreateCellsInstance

protected override DataGridViewCellCollection CreateCellsInstance()

Creates the node's cell collection, and watches it so that the node finds its cell in the tree column as the cells are added.

Returns

The new cell collection.

Expand

public bool Expand()

Opens the node, showing its children.

Returns

true when the node was opened, or was marked to open; false when it was already open or a BinaryTreeListView.BinaryTreeListViewNodeExpanding handler kept it closed.

Remarks

For a node that has not been added to a tree, it marks the node to be open as soon as it is shown.

Open a node only when its parent is open: the children of a node whose parent is closed are placed at the top of the grid. Expand() opens a whole branch from the top down.

Example
BinaryTreeListViewNode europe = sales.Nodes.Add("Europe", 1240000m);
europe.Nodes.Add("United Kingdom", 610000m);
europe.Nodes.Add("Germany", 630000m);
europe.Expand();
See also

Expand

public bool Expand(bool performDeepExpansion)

Opens the node and, if asked, every node beneath it.

Parameters
performDeepExpansion
true to open every descendant as well, from the top down.
Returns

Always true.

Remarks

For a node that has not been added to a tree, it marks only this node to be open when it is shown.

See also

ToString

public override string ToString()

Returns the node's cell values as one string, each followed by a space.

Returns

The values of the cells that have one, in column order; an empty string when the node has no cells.