【发布时间】:2016-11-08 06:10:09
【问题描述】:
我有一个名为 button1 的按钮。使用工具箱,我可以将按钮字体高度设置为双精度值,使用属性然后字体,然后大小,我可以设置为 30.251。但是当我以编程方式设置它时,我不能写 30.251。
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
double value=90.753/3;//the numerator & denominator came from certain computations
Button button1 = new Button();
button1.Font = new Font("Arial", value, FontStyle.Bold);
}
}
}
有什么问题?我需要一个精确的字体高度值,最多 3 个小数位。它显示错误“无法从双精度转换为浮点数”。
【问题讨论】: