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. Listbox

Listbox

Scheduled Pinned Locked Moved Visual Basic
csharpcomquestion
4 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.
  • R Offline
    R Offline
    rstat1
    wrote on last edited by
    #1

    How do you change the Font.Bold property on a listbox in code? Check out my websites: BugTrak Project Home The New Space The Simple Read

    D 1 Reply Last reply
    0
    • R rstat1

      How do you change the Font.Bold property on a listbox in code? Check out my websites: BugTrak Project Home The New Space The Simple Read

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Well, the Font property is read/writable. But, once created, the Font is immutable. You can't modify it. What you have to do is create a new Font object and assign it to the ListBox.Font property. But, you can create a new Font by using an existing one and modifying the parameters as you do so:

      ListBox1.Font = New Font(ListBox1.Font, ListBox1.Font.Style Or FontStyle.Bold)

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Well, the Font property is read/writable. But, once created, the Font is immutable. You can't modify it. What you have to do is create a new Font object and assign it to the ListBox.Font property. But, you can create a new Font by using an existing one and modifying the parameters as you do so:

        ListBox1.Font = New Font(ListBox1.Font, ListBox1.Font.Style Or FontStyle.Bold)

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        R Offline
        R Offline
        rstat1
        wrote on last edited by
        #3

        is there a way to change the bold property on a single item? Check out my websites: BugTrak Project Home The New Space The Simple Read

        D 1 Reply Last reply
        0
        • R rstat1

          is there a way to change the bold property on a single item? Check out my websites: BugTrak Project Home The New Space The Simple Read

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Not through properties. It's all or nothing. The only way to do it is if you were to owner-draw the control. This will give you the ability to draw each item individually, and in the process, change its font. Search the articles for "custom listview" and you'll find examples of owner-drawing the ListView control. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          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