The selection can be configured to operate in three modes via its Mode property, which are:
- Disabled - disables the selection feature
- Single - only a single node can be selected
- Multiple - multiple nodes can be selected
The selection is represented by an instance of the NSelection class, and can be obtained from the Selection property of the NView class.
C# |
Copy Code
|
---|---|
// obtain the selection
NSelection selection = view.Selection;
|
Visual Basic |
Copy Code
|
---|---|
' obtain the selection Dim selection As NSelection = view.Selection |
The selection can be configured to operate in three modes via its Mode property, which are:
The currently selected nodes can be obtained from the Nodes property of the selection:
C# |
Copy Code
|
---|---|
// get the currently selected nodes
NNodeList selectedNodes = selection.Nodes;
|
Visual Basic |
Copy Code
|
---|---|
' get the currently selected nodes Dim selectedNodes As NNodeList = selection.Nodes |
The NSelection class provides a powerful set of methods, which can help you modify the selection. The most important ones are demonstrated in the following example:
C# |
Copy Code
|
---|---|
// make node1 the one and only selected node selection.SingleSelect(node1); // append node2 to the current selection selection.MultiSelect(node2); // toggle the selection state of the node3 (in this case this will select node3) selection.Toggle(node3); // toggle the selection state of the node3 (in this case this will deselect node3) selection.Toggle(node3); // deselect node1 selection.Deselect(node1); // deselect all nodes (in this case only node2) selection.DeselectAll(); |
Visual Basic |
Copy Code
|
---|---|
' make node1 the one and only selected node selection.SingleSelect(node1) ' append node2 to the current selection selection.MultiSelect(node2) ' toggle the selection state of the node3 (in this case this will select node3) selection.Toggle(node3) ' toggle the selection state of the node3 (in this case this will deselect node3) selection.Toggle(node3) ' deselect node1 selection.Deselect(node1) ' deselect all nodes (in this case only node2) selection.DeselectAll() |