Live Chat Icon For mobile
Live Chat Icon

How can I place a border around a PictureBox?

Platform: WinForms| Category: PictureBox

One solution is to use a panel that has a picturebox placed on it with DockStyle.Fill. This will make the picturebox assume the size of the panel. In addition, set the DockPadding.All property to the width of the desired border. Then in the Panel’s OnPaint method, call the baseclass and then paint the desired borders.

Here are both VB and C# projects that illustrate how you might go about this. The derived PicturePanel class has properties that allow you to set the bordersize and color as well as the image that is to be displayed. This sample retrieves the image from an embedded resource. It also uses double buffering to minimize flashing as you resize the control.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.