简体   繁体   中英

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:

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

WPF:

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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