Hi,
How can I collapse regions in syntaxEdit? The following code doesn’t work for me:
var txt =
@"#region Sample
//sample code....
#endregion";
syntaxEdit1.Text = txt;
syntaxEdit1.Outlining.FullCollapse(); //not works
Thanks
Hi,
How can I collapse regions in syntaxEdit? The following code doesn’t work for me:
var txt =
@"#region Sample
//sample code....
#endregion";
syntaxEdit1.Text = txt;
syntaxEdit1.Outlining.FullCollapse(); //not works
Thanks
Hi Peyman,
You need to call csParser1.ForceReparseText() to make sure the text is already parsed before calling FullCollapse(), something like this:
syntaxEdit1.Text = File.ReadAllText(fileInfo.FullName);
syntaxEdit1.Lexer = csParser1;
csParser1.ForceReparseText();
syntaxEdit1.Outlining.AllowOutlining = true;
syntaxEdit1.Outlining.FullCollapse();
Let me know if it works ok for you.
Regards,
Dmitry
Hi Dmitry,
No. unfortunately not works (and regions remain open). I’m using snippet parser so i changed the code as follows:
var txt =
@"#region Sample
//sample code…
#endregion;
syntaxEdit1.Text = txt;
syntaxEdit1.Lexer = csMethodParser;
csMethodParser.ForceReparseText();
syntaxEdit1.Outlining.AllowOutlining = true;
syntaxEdit1.Outlining.FullCollapse();
but above code not works…
Hi Peyman,
I tried this code with our SnippetParser demo, by replacing code inside Form1_Load with the code above. It seems to work fine for me - take a look at the attached screenshot.
Would it be possible to send me a sample project where it does not work so I can have a closer look?
Kind regards,
Dmitry
Hi Dmitry,
You’re right. I put the code in the wrong place. It worked well when I put it in the Form_Load event.
Thanks a lot
Great, thank you for confirming it’s working fine.
Dmitry