繁体   English   中英

在高DPI设置下调整RichTextBox字体大小

[英]Adjust RichTextBox font size under High DPI setting

我的C#应用​​程序包括带有简单文本框和richtext框的网格。 通常,richtext框包含从其他地方复制和粘贴的富文本,并且rtf标记通常包括硬编码字体大小(\\ fsXX,XX半点)。 在大多数情况下,富文本字体大小与简单文本字体大小相同或接近。

当DPI缩放设置为默认值以外的任何值时,富文本会失真,如下所示:

a)当应用程序未设置为DPI识别时,richtext显示为小于简单文本并且模糊。

b)当应用程序设置为DPI时,富文本大于简单文本。

有没有办法允许或强制richtext使用简单文本进行缩放,而不是直接编辑标记?

<script type="text/javascript">
tinyMCE.init({
        mode: "textareas",
        theme: "advanced",
        plugins: "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: false,
        template_external_list_url: "js/template_list.js",
        external_link_list_url: "js/link_list.js",
        external_image_list_url: "js/image_list.js",
        media_external_list_url: "js/media_list.js"
    });
</script>


<td class="textboxmain" style="height:300px; "><asp:TextBox id="textbox1" TextMode="MultiLine" Height="100%" runat="server" placeholder="test............"></asp:TextBox></td>

尝试将其属性WordWrap设置为true

可能解决此问题的一件事是在表单上设置RichTextBox并将表单的AutoScaleMode属性设置为NoneAutoScaleMode枚举文档)

也许您可以使用WPF表单,因此您不必担心不同屏幕的de DPI

请尝试以下操作,仅在.NET Framework 4.5.2及更高版本中受支持。 微软已经为HighDpiAutoresizing提供了一些控件。

<appSettings>
   <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM