none
how to increase the font size on the label

    Question

  • hello friends hope u doing well i have a problem i want to have a Button1 on the Form and i want to have some coding and  that increase the fonts on the label1

    i don't know how to do that thankx

    i am learning vb .net

    Wednesday, March 02, 2011 10:04 AM

Answers

  • Hi Naveed Gul

    Try this

    Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size + 1, FontStyle.Regular)


    Regards, Anoop
    • Proposed as answer by Anoop Sarath Monday, March 21, 2011 11:50 AM
    • Marked as answer by Naveed Gul Wednesday, April 13, 2011 2:24 PM
    Wednesday, March 02, 2011 1:01 PM
  • Hi Naveed,

    Base on your description, I think Anoop's reply can work for you. But, you should set the label1's AutoSize property to "True" first. Then handle the button1's click event , add the code the Anoop provided into the click event. Here is the completed code:

    public MainForm()
        {
          InitializeComponent();
          button1.Click += new EventHandler(button1_Click);
          this.label1.AutoSize = true;
        }
    
    private void button1_Click(object sender, EventArgs e)
        {
          this.label1.Font = new Font(this.label1.Font.FontFamily, this.label1.Font.Size + 1, FontStyle.Regular);
        }
    If it works for you, please mark it as answer. Thanks.
    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jarrey Monday, March 07, 2011 12:06 AM
    • Marked as answer by Aspen VJ Monday, March 14, 2011 7:59 AM
    Friday, March 04, 2011 1:55 AM

All replies

  • Hi Naveed Gul

    Try this

    Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size + 1, FontStyle.Regular)


    Regards, Anoop
    • Proposed as answer by Anoop Sarath Monday, March 21, 2011 11:50 AM
    • Marked as answer by Naveed Gul Wednesday, April 13, 2011 2:24 PM
    Wednesday, March 02, 2011 1:01 PM
  • Hi Naveed,

    Base on your description, I think Anoop's reply can work for you. But, you should set the label1's AutoSize property to "True" first. Then handle the button1's click event , add the code the Anoop provided into the click event. Here is the completed code:

    public MainForm()
        {
          InitializeComponent();
          button1.Click += new EventHandler(button1_Click);
          this.label1.AutoSize = true;
        }
    
    private void button1_Click(object sender, EventArgs e)
        {
          this.label1.Font = new Font(this.label1.Font.FontFamily, this.label1.Font.Size + 1, FontStyle.Regular);
        }
    If it works for you, please mark it as answer. Thanks.
    Vin Jin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jarrey Monday, March 07, 2011 12:06 AM
    • Marked as answer by Aspen VJ Monday, March 14, 2011 7:59 AM
    Friday, March 04, 2011 1:55 AM