Skip to main content
Box

LayoutIterator.MoveNext() Method

Navigates to the next layout element in the layout tree.

Namespace: DevExpress.XtraRichEdit.API.Layout

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

public bool MoveNext()

Returns

Type Description
Boolean

True, on a successful navigation; otherwise, false.

Remarks

If navigation is successful, the LayoutIterator.Current property contains the layout element to which the LayoutIterator has moved.

The MoveNext method can be used to traverse the entire document layout tree. It uses pre-order depth-first traversal. The iterator navigates to the right node of the same LayoutLevel. When there are no more nodes on the right, it goes up to the parent level and accesses the right parent node. Subsequently the iterator navigates to the leftmost child node, and so on.

Example

This code snippet calls different LayoutIterator.MoveNext overloads to illustrate different techniques of tree navigation. Checking the LayoutIterator.IsLayoutValid value is required because the user can modify the document layout in the meantime.

The LayoutIterator.IsStart and LayoutIterator.IsEnd properties indicate whether the iterator reached the start or end of the range for which it has been created, respectively.

bool result = false;
string s = string.Empty;

// Create a new iterator if the document has been changed and the layout is updated.
if (!layoutIterator.IsLayoutValid) CreateNewIterator();

switch (barEditItemRgLevel.EditValue.ToString())
{
    case "Any":
        result = layoutIterator.MoveNext();
        break;
    case "Level":
        result = layoutIterator.MoveNext((LayoutLevel)cmbLayoutLevel.EditValue);
        break;
    case "LevelWithinParent":
        result = layoutIterator.MoveNext((LayoutLevel)cmbLayoutLevel.EditValue, false);
        break;                
}

if (!result)
{
    s = "Cannot move.";
    if (layoutIterator.IsStart) s += "\nStart is reached";
    else if (layoutIterator.IsEnd) s += "\nEnd is reached";
    MessageBox.Show(s);
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the MoveNext() 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.

See Also