【问题标题】:Change default font dialog in c#在 C# 中更改默认字体对话框
【发布时间】:2012-02-29 12:10:16
【问题描述】:

谁能告诉我如何设置FontDialog的默认字体名称、字体大小、字体颜色……

 FontDialog dlg = new FontDialog();
            dlg.ShowColor = true;
  if (dlg.ShowDialog() != DialogResult.OK) return;

dlg.ShowDialog() ;方法应该显示我选择的“microsoft san serif”的字体名称

【问题讨论】:

    标签: c# c#-4.0


    【解决方案1】:

    您只需要在调用ShowDialog 之前设置Font 属性。

    例如:

    dlg.Font = new Font("Consolas", 10);
    //or
    dlg.Font = myCurrentlySelectedFont;
    

    【讨论】:

    • 下划线和删除线属性怎么样
    • var myFont = new Font("Consolas",10); myFont.Underline=true; dlg.Font = myFont
    • abhilash - 下划线是只读的。我认为 Lanke 是在问如何允许下划线和删除线......或者换句话说,你如何在不指定一组非常具体的字体属性的情况下设置 FontFamily
    【解决方案2】:

    还值得指出的是,当从字体对话框中获取字体名称时,您需要的值是:fontDlg.Font.NamefontDlg.Font.FontFamily.Name

    此值将允许您在显示对话框之前正确设置字体名称。

    【讨论】:

      猜你喜欢
      • 2011-11-05
      • 2011-03-18
      • 2011-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      • 2018-01-17
      相关资源
      最近更新 更多