Results 1 to 2 of 2

Thread: Change border color of listbox

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Change border color of listbox

    I have had ample sucess with changing border colors of flat-style textboxes, labels, etc..


    unfortuantely, I still cannot figure how to draw a border properly around a listbox.

    I have been overriding the WndProc method and capturing msg 15, but unfortunately, this seems to draw inside the client area. I can't get to the 1 pixel border around the listbox.

    If I set the BorderStyle of the Listbox to none, I can have a 1 pixel border around the listbox (but its actually drawing inside the client area, which is poor since it leaves lines all over the place.)

    I don't know if inflating the cliprectangle by 1 pixel will solve the problem (not sure if I should bother trying)

    Anyone have success with this?

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    this may seem an unconvensional method, but have you tried setting the listbox on a Panel , with the panel set slightly bigger than the listbox and the backcolor of the panel set to your choice of color that would emulate a color border? eg:
    VB Code:
    1. ListBox1.BorderStyle = BorderStyle.None
    2.         With Panel1
    3.             .BorderStyle = BorderStyle.None
    4.             .BackColor = Color.SteelBlue
    5.             .Height = ListBox1.Height + 4
    6.             .Width = ListBox1.Width + 4
    7.             .Location = New Point(ListBox1.Location.X - 2, ListBox1.Location.Y - 2)
    8.             ListBox1.BringToFront()
    9.         End With
    ~
    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]

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