我希望动态添加的按钮上的文字为粗体。我该怎么做?
这是我的代码:
var b = new Button()
{
Location = new Point(x * 30, y * 30),
Width = 30,
Height = 30,
Tag = new Point(y, x), // game location x, y
BackColor = Color.SkyBlue,
};
答案 0 :(得分:9)
var b = new Button()
{
Location = new Point(x * 30, y * 30),
//...
};
b.Font = new Font(b.Font.Name, b.Font.Size, FontStyle.Bold);
var b = new Button()
{
Location = new Point(x * 30, y * 30),
//...
FontWeight = FontWeights.Bold
};
var b = new Button()
{
Location = new Point(x * 30, y * 30),
//...
};
b.Font.Bold = true;
答案 1 :(得分:5)
尝试此代码的最后一行:
var b = new Button()
{
Location = new Point(x * 30, y * 30),
Width = 30,
Height = 30,
Tag = new Point(y, x), // game location x, y
BackColor = Color.SkyBlue,
Font = new Font("Tahoma", 8.25F, FontStyle.Bold)
};
答案 2 :(得分:1)
Visual Basic中的通用格式为:
btn.Font = New Font("Font Name", Font Size, FontStyle.Bold)