PDA

Click to See Complete Forum and Search --> : Can I change the border colour of a picturebox


Phobbos
Oct 24th, 2001, 07:57 AM
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

Hack
Oct 24th, 2001, 08:47 AM
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.

Phobbos
Oct 24th, 2001, 08:53 AM
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?.

Hack
Oct 24th, 2001, 08:59 AM
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.

Megatron
Oct 24th, 2001, 11:21 AM
Unfortunately, you cannot change the BorderColor. As a work around, change the BorderStyle to flat, and draw your own border.

Megatron
Oct 24th, 2001, 11:31 AM
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.

Private Sub Picture1_Paint()

Dim x1 As Integer
Dim y1 As Integer
x1 = Screen.TwipsPerPixelX
y1 = Screen.TwipsPerPixelY

Picture1.Line (0, 0)-(Picture1.ScaleWidth, 0), vbBlack
Picture1.Line (0, 0)-(0, Picture1.ScaleHeight), vbBlack
Picture1.Line (Picture1.ScaleWidth - x1, 0)-(Picture1.ScaleWidth - x1, Picture1.ScaleHeight), vbBlack
Picture1.Line (0, Picture1.ScaleHeight - y1)-(Picture1.ScaleWidth, Picture1.ScaleHeight - y1), vbBlack

End Sub

AngelFire
Oct 28th, 2001, 06:43 AM
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