I have a problem with .Net's RichTextBox control. It seems that it doesn't support table cell formatting, which is funny because most of the time I create tables I want the cell contents to be right-aligned (numbers, currency).
If I try to open a WordPad document in RichTextBox, it ignores (and actually removes) the commands for cell alignment. I tried several workarounds but didn't succeed.
Can anyone think of an idea to fix this? (without using fixed-width fonts and spaces) This would be the best solution since other code is working fine already, so if only thing needed is a dirty hack, it would be great.
Or is there an open source alternative for .Net Rich Text Editor you can recommend? I need a user control I can embed in my Windows form and access the contents programmatically (create content, or append something). I have searched the web for some time but found only web (Ajax/Javascript) controls.
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). And in that case we will need some extra time to implement a content generator for HTML - although it's much easier to read and generate than RTF IMHO.
What do you guys find best for this purpose?
In C#, RichTextBox control is a textbox which gives you rich text editing controls and advanced formatting features also includes a loading rich text format (RTF) files. Or in other words, RichTextBox controls allows you to display or edit flow content, including paragraphs, images, tables, etc.
To create a RichTextBox control at design-time, you simply drag and drop a RichTextBox control from the Toolbox onto a Form in Visual Studio. Once a RichTextBox is added to a Form, you can move it around and resize it using the mouse and set it's properties and events.
The RichTextBox control allows the user to display, enter, and edit text while also providing more advanced formatting features than the conventional TextBox control. General Description. The RichTextBox control provides a number of properties you can use to apply formatting to any portion of text within the control.
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:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With