Results 1 to 7 of 7

Thread: Can I change the border colour of a picturebox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    85

    Question Can I change the border colour of a picturebox

    Good day all

    I need to find a way of changing the bordercolour of a picturebox to another colour other than black.
    Is that possible??

    PS. Note the spelling of colour!!!
    heehee

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You can change the ForeColor and BackColor, but there is no BorderColor property.

    A workaround might be to put your Picture box in a Label, and size the Label so that it hugs the outline of the Picture box. Then by chaning the Label's forecolor you should be able to simulate a Picturebox's BorderColor.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    85

    Question Sorry yes I see what u mean

    Sorry did not see that, but if you make the picturebox "Flat" it looks like its got a border. Would you beable to change that?.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    but if you make the picturebox "Flat" it looks like its got a border. Would you beable to change that?.
    By change that I assume you mean the color. Nope. We are back to the same old BackColor ForeColor only choice which affects the entire control.

  5. #5
    Megatron
    Guest
    Unfortunately, you cannot change the BorderColor. As a work around, change the BorderStyle to flat, and draw your own border.

  6. #6
    Megatron
    Guest
    This code should get you starting on drawing the outside border. I used black as the colour, but you can change it to whatever you want.

    You'll also need to draw the inside border as well.
    VB Code:
    1. Private Sub Picture1_Paint()
    2.    
    3.     Dim x1 As Integer
    4.     Dim y1 As Integer
    5.     x1 = Screen.TwipsPerPixelX
    6.     y1 = Screen.TwipsPerPixelY
    7.    
    8.     Picture1.Line (0, 0)-(Picture1.ScaleWidth, 0), vbBlack
    9.     Picture1.Line (0, 0)-(0, Picture1.ScaleHeight), vbBlack
    10.     Picture1.Line (Picture1.ScaleWidth - x1, 0)-(Picture1.ScaleWidth - x1, Picture1.ScaleHeight), vbBlack
    11.     Picture1.Line (0, Picture1.ScaleHeight - y1)-(Picture1.ScaleWidth, Picture1.ScaleHeight - y1), vbBlack
    12.  
    13. End Sub

  7. #7
    AngelFire
    Guest

    Re: Can I change the border colour of a picturebox

    Originally posted by Phobbos
    Good day all

    I need to find a way of changing the bordercolour of a picturebox to another colour other than black.
    Is that possible??

    PS. Note the spelling of colour!!!
    heehee
    using subclass and intercept WM_PAINT to draw your own border

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