【问题标题】:Adjust RichTextBox font size under High DPI setting在高 DPI 设置下调整 RichTextBox 字体大小
【发布时间】:2012-11-08 20:14:54
【问题描述】:

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

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

a) 当应用程序未设置为 DPI 感知时,富文本显示比简单文本小且模糊。

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

有没有办法允许或强制富文本与简单文本一起缩放,而不是直接编辑标记?

【问题讨论】:

  • 你试过richtextbox v5吗?
  • 可以添加一些截图吗?它可能会更容易帮助您...
  • 简单文本框的字体是如何定义的,是磅还是像素?
  • 还有一点,Windows 上的高 dpi 世界比您目前看到的要复杂一些。除了让应用程序以 96 dpi 工作外,您还希望在 dpi 介于 96 和 149 之间然后 > 150 进行测试。设置为 false 时导致拉伸的 dpi 感知标志在 dpi 至少为 150 之前不会开始工作。

标签: c# richtextbox scaling dpi


【解决方案1】:

尝试将其属性 WordWrap 设置为 true

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:
      <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>
      

      【讨论】:

      • 同时下载 tinymce 3 派对工具
      【解决方案4】:

      请尝试以下方法,仅在 .NET Framework 4.5.2 及更高版本中受支持。 Microsoft 已经涵盖了更多用于 HighDpiAutoresizing 的控件。

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

      【讨论】:

      【解决方案5】:

      也许你可以使用WPF表单,这样你就不用担心不同屏幕的de DPI了

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-27
        • 1970-01-01
        相关资源
        最近更新 更多