New to Telerik UI for WinFormsStart a free 30-day trial

Collapsing and Expanding All Nodes in SyntaxEditor

Updated on Mar 10, 2026

Environment

Product VersionProductAuthor
2026.1.210RadSyntaxEditor for WinFormsNadya Karaivanova

Description

The following article demonstrates how to collapse and expand nodes programmatically in the SyntaxEditor component for UI for WinForms.

Solution

To collapse or expand all nodes in the SyntaxEditor, use the following code snippet. It iterates through the FoldingRegions and toggles their IsFolded property.

  1. Access the SyntaxEditorElement.FoldingManager.FoldingRegions.
  2. Loop through each FoldingRegion.
  3. Toggle the IsFolded property.

Here is the example code:

C#

private void radButton1_Click(object sender, EventArgs e)
{
    // Collapse/Expand all nodes
    foreach (FoldingRegion region in this.radSyntaxEditor1.SyntaxEditorElement.FoldingManager.FoldingRegions)
    {
        region.IsFolded = !region.IsFolded;
    }
}

See Also