Expand Collapse programmatically

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Hidden
Version: 4.0.0282
Avatar
I can't find out how to implement next behavior in XML Syntax editor:

I have 2 buttons on form: Expand and Collapse.

1. When user clicks "Collapse" button - if the cursor inside the node, then it is collapsing.
2. When user clicks "Expand" button - if the cursor stands on collapsed node - it is expanding.

How to achieve this?

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is implemented in the MainForm.cs sample code and is demoed in the SDI Editor sample:
// Toggle outlining expansion
OutliningNode node = editor.Document.Outlining.RootNode.FindNodeRecursive(editor.Caret.Offset);
if (node != null)
    node.ToggleExpansion();
else if (editor.Caret.Offset > 0) {
    // Since no node was found at the caret's offset, check to see if there is a node ending right before it
    node = editor.Document.Outlining.RootNode.FindNodeRecursive(editor.Caret.Offset - 1);
    if (node != null)
        node.ToggleExpansion();
}
The only thing you'd need to change is make it only toggle if it is not the expanded/collapsed you want.


Actipro Software Support

Posted 14 years ago by Hidden
Avatar
Thanks for help. This is exactly what I need.
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.