How do you programatically set Label Font size

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    How do you programatically set Label Font size

    I am trying to set the font size on a Label control. Seems like a simple
    item but I can't find a way to do it.
    I can set other properties for a Label like Borderstyle, BackColor,
    Fontstyle=BOLD etc.
    I'm using VB.NET 2003.

    Thanks for any feedback



  • Teemu

    #2
    Re: How do you programatically set Label Font size


    "Mike" <mikea365h@hotm ail.comkirjoitt i viestissä
    news:SpqdnW3Cy8 Jzk7rVnZ2dnUVZ_ vSdnZ2d@pghconn ect.com...
    >I am trying to set the font size on a Label control. Seems like a simple
    >item but I can't find a way to do it.
    I can set other properties for a Label like Borderstyle, BackColor,
    Fontstyle=BOLD etc.
    I'm using VB.NET 2003.
    You have to create a new instance of font. If you need just to change the
    size, this

    Label1.Font = New Font(Label1.Fon t.FontFamily,20 )

    might be the easiest way. If you need more options, you can use another
    constructor to create for example bolded text.

    -Teemu

    Comment

    • kimiraikkonen

      #3
      Re: How do you programatically set Label Font size

      On May 11, 6:21 pm, "Mike" <mikea3...@hotm ail.comwrote:
      I am trying to set the font size on a Label control. Seems like a simple
      item but I can't find a way to do it.
      I can set other properties for a Label like Borderstyle, BackColor,
      Fontstyle=BOLD etc.
      I'm using VB.NET 2003.
      >
      Thanks for any feedback
      Hi,
      Using VB 2005,
      Could you find "font" on label's property window then you should be
      able to tweak front types / sizes.

      Or if you want to set font of label on runtime, you can use for
      example;

      Dim myfont As New Font("Sans Serif", 26, FontStyle.Regul ar)
      label1.font = myfont

      ... where argument "26" is your font size that you can set to what you
      desire.

      Thanks,

      Onur Güzel

      Comment

      • Armin Zingler

        #4
        Re: How do you programatically set Label Font size

        "Mike" <mikea365h@hotm ail.comschrieb
        I am trying to set the font size on a Label control. Seems like a
        simple item but I can't find a way to do it.
        I can set other properties for a Label like Borderstyle, BackColor,
        Fontstyle=BOLD etc.
        I'm using VB.NET 2003.
        >
        Thanks for any feedback

        Assign a Font object to the Font property.


        Armin

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: How do you programatically set Label Font size


          Ozur,

          Dim myfont As New Font("Sans Serif", 26, FontStyle.Regul ar)
          label1.font = myfont

          this is the same in 2003

          Cor


          Comment

          • Jack Jackson

            #6
            Re: How do you programatically set Label Font size

            On Sun, 11 May 2008 09:21:26 -0700 (PDT), kimiraikkonen
            <kimiraikkonen8 5@gmail.comwrot e:
            >On May 11, 6:21 pm, "Mike" <mikea3...@hotm ail.comwrote:
            >I am trying to set the font size on a Label control. Seems like a simple
            >item but I can't find a way to do it.
            >I can set other properties for a Label like Borderstyle, BackColor,
            >Fontstyle=BO LD etc.
            >I'm using VB.NET 2003.
            >>
            >Thanks for any feedback
            >
            >Hi,
            >Using VB 2005,
            >Could you find "font" on label's property window then you should be
            >able to tweak front types / sizes.
            >
            >Or if you want to set font of label on runtime, you can use for
            >example;
            >
            >Dim myfont As New Font("Sans Serif", 26, FontStyle.Regul ar)
            >label1.font = myfont
            >
            >... where argument "26" is your font size that you can set to what you
            >desire.
            >
            >Thanks,
            >
            >Onur Güzel
            I would prefer:
            label1.Font = New Fontlabel1.Font .FontFamily, 26, label1.Font.Sty le)

            That way everything is the same except the size even if the font
            family or style change later.

            Comment

            Working...