Results 1 to 6 of 6

Thread: Change font size by clicking on + or - buttons

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Change font size by clicking on + or - buttons

    How can I change the font size only of a label's text property by clicking on a button. Basically, I want two buttons. One to increase the size and one to decrease the size.

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    VB Code:
    1. Dim x As Integer
    2.     Dim f As String
    3.  
    4. '///^^^ referenced so available from all controls.
    5. '//////////
    6.  
    7.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    8.         x = Label1.Font.Size
    9.         f = Label1.Font.Name
    10.         Label1.Font = New Drawing.Font(f, x + 1)
    11.     End Sub
    12.  
    13.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    14.         x = Label1.Font.Size
    15.         f = Label1.Font.Name
    16.         Label1.Font = New Drawing.Font(f, x - 1)
    17.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3
    Addicted Member PeteD's Avatar
    Join Date
    Jun 2003
    Location
    Sydney
    Posts
    158
    to increase:

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

    to decreace:

    Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size - 1)

  4. #4
    Addicted Member PeteD's Avatar
    Join Date
    Jun 2003
    Location
    Sydney
    Posts
    158
    damn.. beat me to it!

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    lol , must have my finger on the trigger today
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Thanks!

    Howdy Gunslingers!

    Both responses are greatly appreciated!

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width