Search
DiagramItem.Query Method
See Also
 





Returns the items that can be reached from this item by following the path specified in the given query expression.

Namespace: MindFusion.Diagramming
Assembly: MindFusion.Diagramming

 Syntax

C#  Copy Code

public DiagramItemCollection Query (
    string query
)

Visual Basic  Copy Code

Public Function Query( _
    query As String _
) As DiagramItemCollection

 Parameters

query

A query expression consisting of selectors and boolean predicates.

 Return Value

A collection of the found items.

 Remarks

The query string consists of selectors, where each selector specifies the next items that should be selected starting from the current one.

The following selectors can be applied to a node:

links

Selects all links connected to the current node

inlinks

Selects the incoming links of the current node

outlinks

Selects the outgoing links of the current node

parent

Selects the parent item of the current node if it is in a group

children

Selects the child nodes of the current node if it is in a group

The following selectors can be applied to a link:

nodes

Selects the two nodes connected by the current link

origin

Selects the Origin node of the current link

destination

Selects the Destination node of the current link

children

Selects the child nodes of the current link if it is in a group.

Selectors must be separated by the / character. The results returned by a selector can be also filtered using a predicate expression, enclosed in square brackets after the selector name. The predicate expression can include C# like boolean and arithmetic operators, and one of the following property identifiers:

tag

Returns the value of the Tag property.

text

Returns the value of the Text property.

weight

Returns the value of the Weight property.

 Example

The following code selects nodes two levels below the current one in a tree or layered graph.

C#  Copy Code

DiagramItemCollection items = diagram.ActiveItem.Query(
    "outlinks/destination/outlinks/destination");
diagram.Selection.Clear();
foreach (DiagramItem item in items)
    item.Selected = true;

The following code finds the neighbors of the currently selected node that can be reached from it by following links with Weight greater than 3.

C#  Copy Code

DiagramItemCollection items = diagram.ActiveItem.Query(
 "outlinks[weight>3]/destination");

The following example finds the destination nodes of links labeled "exception" going out of children of the current node's group.

C#  Copy Code
DiagramItemCollection items = diagram.ActiveItem.Query(
    "children/outlinks[text==\"exception\"]/destination");

 See Also