I'd like to have my regions folded when new .CS is loaded.. is there a way to programatically fold / unfold the display text?
Closest thing I could find was this: radSyntaxEditor1.SyntaxEditorElement.FoldingManager.UnfoldAllRegionsContaningIndex(1);
Thanks! Jason
1 Answer, 1 is accepted
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Aug 2020, 06:36 AM
Hello, Jason,
The SyntaxEditorElement.FoldingManager offers the FoldingRegions collection. You can iterate its items and set the FoldingRegion.IsFolded to true/false according to the fold/unfold action that you want to perform:
publicRadForm1()
{
InitializeComponent();
CSharpTagger currentLanguageTagger = new Telerik.WinForms.Controls.SyntaxEditor.Taggers.CSharpTagger(this.radSyntaxEditor1.SyntaxEditorElement);
this.radSyntaxEditor1.TaggersRegistry.RegisterTagger(currentLanguageTagger);
CSharpFoldingTagger foldingTagger = new Telerik.WinForms.Controls.SyntaxEditor.Taggers.CSharpFoldingTagger(this.radSyntaxEditor1.SyntaxEditorElement);
foldingTagger.FoldingRegionDefinitions.Add(new FoldingRegionDefinition("#region", "#endregion"));
radSyntaxEditor1.TaggersRegistry.RegisterTagger(foldingTagger);
using (StreamReader reader = new StreamReader(@"..\..\document.cs"))
{
this.radSyntaxEditor1.Document = new TextDocument(reader);
}
}
privatevoidradButton1_Click(object sender, EventArgs e)
{
foreach (FoldingRegion region inthis.radSyntaxEditor1.SyntaxEditorElement.FoldingManager.FoldingRegions)
{
region.IsFolded = true;
}
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik