更改c#中的默认字体对话框

NIl*_*nke 1 c# c#-4.0

任何人都可以告诉我如何设置FontDialog的默认字体名称,字体大小,字体颜色..

 FontDialog dlg = new FontDialog();
            dlg.ShowColor = true;
  if (dlg.ShowDialog() != DialogResult.OK) return;
Run Code Online (Sandbox Code Playgroud)

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

Dav*_*haw 7

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

例如:

dlg.Font = new Font("Consolas", 10);
//or
dlg.Font = myCurrentlySelectedFont;
Run Code Online (Sandbox Code Playgroud)

  • `var myFont = new Font("Consolas",10); myFont.Underline = TRUE; dlg.Font = myFont` (3认同)