C#如何禁用winforms中的richtextbox自动文本换行? [英] C# How to disable the richtextbox auto text wrap in winforms?

查看:317
本文介绍了C#如何禁用winforms中的richtextbox自动文本换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我这里有一个小问题,但令人沮丧.在我现在正在从事的项目中,我编写了一个WYSIWYG HTML编辑器,其中的RichView框用于代码视图,而Web浏览器用于可编辑预览,它们​​都根据所做的更改而彼此更新.到目前为止,一切都很好.让我感到沮丧的是,当我更改以下文本时,我似乎无法以任何方式禁用richtextbox的自动textwrap:

Hello everybody, I''m having a little but frustrating problem here. In the project I''m working on right now I programmed a WYSIWYG HTML editor with a richtextbox for the codeview and a webbrowser for the editable preview and they are both updating each other depending on which of them are changes made. So far so good. Whats frusttrating for me is that it seems that i can''t by any means disable the auto textwrap of the richtextbox when I change the text like:

rTBxCode.Text = WBHTML.DocumentText;



我总是将HTML文本弄混,很难以这种方式理解语法.有没有办法保持格式和换行符?我将不胜感激.

我以这种方式将richtextbox传递到Web浏览器:



I always get the HTML text blobbed together and it''s hard to make sense of the syntax that way. is there a way to keep the format and linebreaks? I would apreciate any help.

i pass the richtextbox to the webbrowser in this way:

try
{
    string current_source = rTBxCode.Text;
    StreamWriter stream = new StreamWriter("index.html");
    stream.Write(current_source);
    stream.Close();
    string place = Directory.GetCurrentDirectory();
    string url = place + "/index.html";
    WBHTML.Refresh(WebBrowserRefreshOption.Completely);
    WBHTML.Navigate(url);
    rTBxCode.Focus();
}
catch (Exception ex)
{
    CreateLogFiles log = new CreateLogFiles();
    log.ErrorLog("C:\\", "Error HTMLEditor time2_tick funcion. " +ex.Message , "ProgrammErrorLog.txt");
}

推荐答案

您可能会开始研究将RTF转换为HTML的其他策略,例如使用XSL,如本CP文章中所述:"XHTML2RTF:An基于XSL的HTML到RTF转换工具" [ ^ ].

并查看此MSDN文章:在RTF和HTML之间转换" [ ^ ].

您是否对RTF文件如何告知其使用者自动换行"进行过任何考古"研究?

最好,比尔
You might start by examining other strategies for converting RTF to HTML, such as by using XSL, as in this CP article: "XHTML2RTF: An HTML to RTF conversion tool based on XSL"[^].

And check out this MSDN article: "Converting between RTF and HTML"[^].

Have you done any ''archaeology'' on how an RTF file tells its consumers that word-wrap is "on" ?

best, Bill


这篇关于C#如何禁用winforms中的richtextbox自动文本换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆