New to Telerik UI for WinForms? Start a free 30-day trial
Collapsing and Expanding All Nodes in SyntaxEditor
Updated on Mar 10, 2026
Environment
| Product Version | Product | Author |
|---|---|---|
| 2026.1.210 | RadSyntaxEditor for WinForms | Nadya 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.
- Access the
SyntaxEditorElement.FoldingManager.FoldingRegions. - Loop through each
FoldingRegion. - Toggle the
IsFoldedproperty.
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;
}
}