LayoutIterator.MovePrevious() Method
Navigates to the previous 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
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 MovePrevious method can be used to traverse the entire document layout tree. It uses pre-order depth-first traversal. The iterator navigates to the left node of the same LayoutLevel. When there are no more nodes on the left, it goes up to the parent level and accesses the left parent node. Subsequently the iterator navigates to the rightmost child node, and so on.
Example
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.MovePrevious();
break;
case "Level":
result = layoutIterator.MovePrevious((LayoutLevel)cmbLayoutLevel.EditValue);
break;
case "LevelWithinParent":
result = layoutIterator.MovePrevious((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);
}