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. Border Color customization in ListBox and CheckedListBox

Border Color customization in ListBox and CheckedListBox

Scheduled Pinned Locked Moved C#
questiongraphicsarchitecture
2 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.
  • V Offline
    V Offline
    VPMahank
    wrote on last edited by
    #1

    With BorderStyle set to Fixed Single, in the Paint method I tried to draw my own border color but the Paint would never get called for ListBox/CheckedListBox. Is there any difference from ListBox/CheckedListBox and other controls. I know that we need to override OnDrawItem , OnMeasureItem to customize the items in the ListBox but how do I change the border color of the ListBox itself? protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.BorderStyle == BorderStyle.FixedSingle) System.Windows.Forms.ControlPaint.DrawBorder(e.Graphics, ClientRectangle, _borderColor, ButtonBorderStyle.Solid); } Thanks in advance, VPMahank

    A 1 Reply Last reply
    0
    • V VPMahank

      With BorderStyle set to Fixed Single, in the Paint method I tried to draw my own border color but the Paint would never get called for ListBox/CheckedListBox. Is there any difference from ListBox/CheckedListBox and other controls. I know that we need to override OnDrawItem , OnMeasureItem to customize the items in the ListBox but how do I change the border color of the ListBox itself? protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.BorderStyle == BorderStyle.FixedSingle) System.Windows.Forms.ControlPaint.DrawBorder(e.Graphics, ClientRectangle, _borderColor, ButtonBorderStyle.Solid); } Thanks in advance, VPMahank

      A Offline
      A Offline
      Andy Moore
      wrote on last edited by
      #2

      You may have to handle WM_NCPAINT to do this since the border is not part of the client area. Deus caritas est

      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