0

I'm currently developing an IDE and Im working on Code-Folding codes now . I'm thinking to use a TreeView as for it has a collapse and expand property but i dunno/not sure how can I implement it on RichTextBox .

Even an Initial Code showing if interaction within RichTextBox and TreeView will be much appreciated .

like:

{

}

then RichTextBox will have a line indicating till where to collapse .

Thanks a lot in advance!

Elegiac
  • 129
  • 1
  • 17

2 Answers2

2

It doesn't seem feasible to include a TreeView inside a RichTextBox. From my experience, building something atop the RTB is quite problematic and doesn't render the desired result without having quite a lot of quirks.

I suggest taking a look at the Fast-Colored-TextBox:
http://www.codeproject.com/Articles/161871/Fast-Colored-TextBox-for-syntax-highlighting

Or possibly building a similar control from scratch (if you too suffer from NIH) instead of attempting to extend the RTB.

DeadDog
  • 241
  • 2
  • 6
0

If you really need your own code editor you should really think about taking Avalon Edit. It is able to rebuilt an Visual Studio Editor. So it has all you feature you need (and more).

I know it is a WPF component and not winforms. But it is quite easy to host a WPF control within winforms. So better take this route, cause trying to interweave a tree view with a rich text box will never match exactly what you like (just think about finding out the pixel size of a textline if you are using different fonts or how to determine line wrapping).

Oliver
  • 43,366
  • 8
  • 94
  • 151
  • I also recommend a "real" source code editor, a Windows.Forms one would be ICSharpCode.TextEditor: http://www.codeproject.com/Articles/30936/Using-ICSharpCode-TextEditor – Ray Oct 18 '13 at 06:32
  • @Oliver , thanks sirs for the help but I have those now ... all i wanted was separate code for code-folding – Elegiac Oct 18 '13 at 06:43
  • same as @PacMani i already saw those but still thanks ... i needed separate code for code-folding sirs – Elegiac Oct 18 '13 at 06:44
  • @Elegiac: However, be careful before you put too much work into the RichTextBox. We fell into the abyss trying to implement special things with it, because the RTB often didn't work as expected ;-) – Ray Oct 18 '13 at 07:39
  • but it is Possible@PacMani ? – Elegiac Oct 18 '13 at 08:26