Results 1 to 6 of 6

Thread: Change size of every font on every form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Posts
    21

    Change size of every font on every form

    is there a way i can change the font size on every label,textbox,etc. on the condition that a check box has been clicked
    this is what i have so far:
    code:
    If CheckBox1.Checked Then
    Dim ctrl As Control = Me.GetNextControl(Me, True) 'thanks jmc
    Do Until ctrl Is Nothing
    Dim f As Font = New Font(ctrl.Font.FontFamily, 18.0F, ctrl.Font.Style)
    ctrl.Font = f
    ctrl = Me.GetNextControl(ctrl, True)
    Loop
    End If
    End Sub

    it only changes the font size on the current form

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,697

    Re: Change size of every font on every form

    It would probably be easier to change the font size of the Form rather than each individual control because the control's font is determined based on it's parent's font:
    Code:
    Me.Font = New Font(Me.Font.FontFamily, <new size here>)
    Then you'd just do that for each form:
    Code:
    Me.Font = New Font(Me.Font.FontFamily, <new size here>)
    Form2.Font = Me.Font
    Form3.Font = Me.Font
    'Etc...
    Last edited by dday9; Feb 26th, 2015 at 02:57 PM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Posts
    21

    Re: Change size of every font on every form

    i get an error message saying font family is not a member of this form

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,697

    Re: Change size of every font on every form

    I forgot to add the Font object. I'm free-typing it...

    I've edited it.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Posts
    21

    Re: Change size of every font on every form

    all this seems to do is enlarge the forms window, it doesn't affect the font

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,697

    Re: Change size of every font on every form

    I'm not at a computer with Visual Studios to check it, but I was under the impression that the controls took on the same font as their parent. I'll have to wait until I get home to check it out.

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