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. C#
  4. Changing Fontsizes in Controls

Changing Fontsizes in Controls

Scheduled Pinned Locked Moved C#
graphicsquestionlearning
3 Posts 2 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.
  • M Offline
    M Offline
    MCSD Gandalf
    wrote on last edited by
    #1

    It is always the simple things that get ya'. Is it me or does MS INSIST on making the easy things hard to do? All I need to do is increase the fontsize of a control. Seems I should be able to just add to the current fontsize, but of course I am not allowed to do that. Oh by the way I can't use the Font Dialog. Here is what I've come up with. Anyone have any better ideas? private void button3_Click(object sender, System.EventArgs e) { System.Drawing.Font currentFont= listBox1.Font; FontStyle fs= currentFont.Style; switch (currentFont.Size.ToString()) { case "8": listBox1.Font = new Font(currentFont.FontFamily, 10, fs); break; case "10": listBox1.Font = new Font(currentFont.FontFamily, 12, fs); break; case "12": listBox1.Font = new Font(currentFont.FontFamily, 15, fs); break; case "15": listBox1.Font = new Font(currentFont.FontFamily, 8, fs); break; } } Thanks in advance. WhiteWizard(aka Gandalf)

    L 1 Reply Last reply
    0
    • M MCSD Gandalf

      It is always the simple things that get ya'. Is it me or does MS INSIST on making the easy things hard to do? All I need to do is increase the fontsize of a control. Seems I should be able to just add to the current fontsize, but of course I am not allowed to do that. Oh by the way I can't use the Font Dialog. Here is what I've come up with. Anyone have any better ideas? private void button3_Click(object sender, System.EventArgs e) { System.Drawing.Font currentFont= listBox1.Font; FontStyle fs= currentFont.Style; switch (currentFont.Size.ToString()) { case "8": listBox1.Font = new Font(currentFont.FontFamily, 10, fs); break; case "10": listBox1.Font = new Font(currentFont.FontFamily, 12, fs); break; case "12": listBox1.Font = new Font(currentFont.FontFamily, 15, fs); break; case "15": listBox1.Font = new Font(currentFont.FontFamily, 8, fs); break; } } Thanks in advance. WhiteWizard(aka Gandalf)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If you want to increase fontsize, then see this:

      float fontsize = this.listBox1.Font.Size;
      fontsize++;
      this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif",
      fontsize,
      System.Drawing.FontStyle.Regular,
      System.Drawing.GraphicsUnit.Point,
      ((System.Byte)(0)));

      M 1 Reply Last reply
      0
      • L Lost User

        If you want to increase fontsize, then see this:

        float fontsize = this.listBox1.Font.Size;
        fontsize++;
        this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif",
        fontsize,
        System.Drawing.FontStyle.Regular,
        System.Drawing.GraphicsUnit.Point,
        ((System.Byte)(0)));

        M Offline
        M Offline
        MCSD Gandalf
        wrote on last edited by
        #3

        Thanks! I combined your code with mine and got just what I needed. Here's what I ended up with: private void button3_Click(object sender, System.EventArgs e) { System.Drawing.Font currentFont= listBox1.Font; FontStyle fs= currentFont.Style; float fontsize = this.listBox1.Font.Size; fontsize++; if (fontsize > 20) { fontsize = 8; } listBox1.Font = new Font(currentFont.FontFamily, fontsize, fs); } Gandalf

        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