How to make button text bold?

14,697

Solution 1

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;

Solution 2

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

Solution 3

The generic format for this in visual basic would be:

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

Share:
14,697

Related videos on Youtube

Tim Kathete Stadler
Author by

Tim Kathete Stadler

Currently working at Stemmer Imaging ♦

Updated on October 12, 2022

Comments

  • Tim Kathete Stadler
    Tim Kathete Stadler over 1 year

    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,
    };
    
    • Abin
      Abin over 10 years
      what kind of application u have ? is it WPF or WinForm or web app ?