gpt4 book ai didi

c# - 使用 System.Drawing.Font 限制字体大小?

转载 作者:行者123 更新时间:2023-12-02 13:27:06 26 4
gpt4 key购买 nike

我正在使用内置的字体对话框来选择字体大小和样式。字体大小范围显示从 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com