RichTextBox (.NET Winforms) problem (or alternative)

孤人 提交于 2019-12-05 11:04:41
Hoffmania

If you are still going down the .net winforms path then inherit from RichTextBox and add the following code, it will transform the RichTextBox into something "useable":

[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;
     }
}

Sourced from here.

Have a nice day:)

3.There are also HTML WYSIWYG editors which I could use, but they are all basically a IE browser embedded and edited using MSHTML, and it feels a bit strange to have that in a Winforms app (maybe I am wrong).

I've written a HTML WYSIWYG editor: the ModelText HTML Control for .NET. It's pure managed code, with no dependency on a browser; it exports .NET APIs, which let you access its contents programmatically.

The next version to be released (in a few days from now) will support cell alignment (by supporting the CSS "text-align" property).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!