简体   繁体   English

如何使按钮文本加粗?

[英]How to make button text bold?

I want to have the text on my dynamicly added buttons bold.我想让动态添加的按钮上的文本加粗。 How do I do that?我该怎么做?

Here is my code:这是我的代码:

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,
};

Windows Forms: Windows 窗体:

var b = new Button()
{
    Location = new Point(x * 30, y * 30),
    //...
};
b.Font = new Font(b.Font.Name, b.Font.Size, FontStyle.Bold);

WPF: WPF:

var b = new Button()
{
    Location = new Point(x * 30, y * 30),
    //...
    FontWeight = FontWeights.Bold
};

ASP.NET ASP.NET

var b = new Button()
{
    Location = new Point(x * 30, y * 30),
    //...
};
b.Font.Bold = true;

Try the last line of this code:试试这段代码的最后一行:

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)
};

Visual Basic 中的通用格式是:

btn.Font = New Font("Font Name", Font Size, FontStyle.Bold)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM