RichTextBox (.NET Winforms) 问题(或替代方案)
我对 .Net 的 RichTextBox 控件。 它似乎不支持表格单元格格式,这很有趣,因为大多数时候我创建表格时我希望单元格内容右对齐(数字、货币)。
如果我尝试在 RichTextBox 中打开写字板文档,它会忽略(实际上删除)单元格对齐命令。 我尝试了几种解决方法但没有成功。
有人能想出解决这个问题的办法吗? (不使用固定宽度的字体和空格)这将是最好的解决方案,因为其他代码已经工作正常,所以如果只需要一个肮脏的黑客,那就太好了。
或者您可以推荐 .Net 富文本编辑器的开源替代品吗? 我需要一个可以嵌入 Windows 表单并以编程方式访问内容的用户控件(创建内容或附加内容)。 我在网络上搜索了一段时间,但只找到了网络(Ajax/Javascript)控件。
还有一些我可以使用的 HTML WYSIWYG 编辑器,但它们基本上都是使用 MSHTML 嵌入和编辑的 IE 浏览器,在 Winforms 应用程序中使用它感觉有点奇怪(也许我错了)。 在这种情况下,我们将需要一些额外的时间来实现 HTML 内容生成器 - 尽管它比 RTF 恕我直言更容易阅读和生成。
你们觉得什么最适合这个目的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您仍然沿着 .net winforms 路径前进,然后继承 RichTextBox 并添加以下代码,它将把 RichTextBox 转换为“可用”的内容:
源自 此处。
祝你今天过得愉快:)
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":
Sourced from here.
Have a nice day:)
我编写了一个 HTML WYSIWYG 编辑器:ModelText HTML Control for .NET。 它是纯托管代码,不依赖于浏览器; 它导出 .NET API,使您可以通过编程方式访问其内容。
即将发布的下一个版本(几天后)将支持单元格对齐(通过支持 CSS“text-align”属性)。
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).