RichTextBox (.NET Winforms) issue (or alternative)

I have a problem with .Net RichTextBox . It doesn't seem to support formatting table cells, which is ridiculous, because most of the time when I create tables, I want the contents of the cell to be right-aligned (numbers, currency).

If I try to open a WordPad document in a RichTextBox, it ignores (and actually deletes ) the cell alignment commands. I tried several workarounds but failed.

  • Can anyone think of an idea to fix this? (without using fixed-width fonts and spaces) This would be a better solution, as the other code is already working fine, so if necessary, this is a dirty hack, that would be great.

  • Or is there an open source alternative for .Net Rich Text Editor that you can recommend? I need a user control that I can embed in my Windows form and programmatically access the content (create content or add something). For a while I was looking for a website, but found only controls (Ajax / Javascript).

  • There are also WYSIWYG HTML editors that I could use, but they are mostly IE browsers built-in and edited using MSHTML, and it's a little strange that in the Winforms application (maybe I'm wrong), And in this case we need additional time to create a content generator for HTML - although it is much easier to read and generate than RTF IMHO.

  • What do you guys find better for this purpose?

+4
source share
2 answers

If you still omit the .net winforms path, then you inherit from RichTextBox and add the following code, it will convert RichTextBox to something “useful”:

[DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName); protected override CreateParams CreateParams { get { CreateParams cparams = base.CreateParams; if (LoadLibrary("msftedit.dll") != IntPtr.Zero) { cparams.ClassName = "RICHEDIT50W"; } return cparams; } } 

Retrieved from here .

A good day:)

+9
source

3. There are also WYSIWYG HTML editors that I could use, but they are mostly IE browsers built in and edited using MSHTML, and it's a little strange that in the Winforms application (maybe I'm wrong).

I wrote the WYSIWYG HTML editor: ModelText HTML Control for .NET . This is pure, managed code, browser independent; it exports .NET APIs that allow you to programmatically access its contents.

The next version, which will be released (a few days after that), will support cell alignment (by supporting the CSS text-align property).

+2
source

All Articles