我正在使用内置的字体对话框来选择字体大小和样式。字体大小范围显示从 8 到 72。我需要限制用户不要选择超过 20 的大小。是否可以禁用 22 的字体大小或从 22 开始根本不显示它们?我在 Font 类中没有看到任何属性可以执行此操作?感谢您的任何建议。
最佳答案
I don't see any property on the Font class to do this?
这是因为它是 FontDialog 类的属性,而不是 Font 类的属性。例如:
using (var dlg = new FontDialog()) {
dlg.MaxSize = 20; // <=== Here
if (dlg.ShowDialog() == DialogResult.OK) {
// etc...
}
}
您会发现您不可能选择大于 20 的尺寸。
关于c# - 使用 System.Drawing.Font 限制字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26222597/