Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to set font size of a control dynamically

How to set font size of a control dynamically

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amer Rehman 0
    wrote on last edited by
    #1

    Hi How can I set the font size of a control dynamically e.g. label. The problem is that the font size property is readonly. Thanks

    reman

    T A M 3 Replies Last reply
    0
    • A Amer Rehman 0

      Hi How can I set the font size of a control dynamically e.g. label. The problem is that the font size property is readonly. Thanks

      reman

      T Offline
      T Offline
      Tom Deketelaere
      wrote on last edited by
      #2

      you have to assign a new font to the font (not entirly shure) property: dim f as new font ("Arial",12,...) label.font = f hope this helps

      If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.

      1 Reply Last reply
      0
      • A Amer Rehman 0

        Hi How can I set the font size of a control dynamically e.g. label. The problem is that the font size property is readonly. Thanks

        reman

        A Offline
        A Offline
        AliAmjad
        wrote on last edited by
        #3

        You can easily change the Font Size,Style,Family by using any of the following code:

            Dim fdlg As New FontDialog()
            If fdlg.ShowDialog = DialogResult.OK Then
        
                Me.Label1.Font = fdlg.Font
        
            End If
        

        Alternatively you can change the font by using this code:

            Dim \_font As New Font("verdana", 24, FontStyle.Italic)
            Me.Label1.Font = \_font
        

        Hope it helps. AliAmjad (MCP)

        1 Reply Last reply
        0
        • A Amer Rehman 0

          Hi How can I set the font size of a control dynamically e.g. label. The problem is that the font size property is readonly. Thanks

          reman

          M Offline
          M Offline
          Mitesh Darji
          wrote on last edited by
          #4

          please try following code for increase font size (Label) Me.Label1.Font = New System.Drawing.Font("arial", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Size = New System.Drawing.Size(208, 24) Me.Label1.Text = "Label Font Size Change"

          mitesh

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups