Reputation: 2555
I have a form that I am using as a splash screen. Since it is a splash it does not have a border on it. The splash screen is white so when it loads against something else that is white it looks funy. I was thinking of adding an outline around the form about 1 px or so to give it a thin border. Think of it as adding a stroke to an image in photoshop. How would I do this? I am using vb.net.
Upvotes: 2
Views: 5521
Reputation: 889
You could also use the following:
Private Sub frm_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
ControlPaint.DrawBorder(e.Graphics, Me.ClientRectangle, Color.Black, ButtonBorderStyle.Outset)
End Sub
Color and ButtonBorderStyle can both be customized to what you need.
Upvotes: 2
Reputation: 1
If you use docked panels in the form, this border might now show. I suggest providing a 'Padding' of 1 on all edge of the form if you use docked panel in your form. This works perfectly.
Upvotes: 0
Reputation: 225015
You could use GDI+:
Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
MyBase.OnPaintBackground(e)
Dim rect As New Rectangle(0, 0, Me.ClientSize.Width - 1, Me.ClientSize.Height - 1)
e.Graphics.DrawRectangle(Pens.Black, rect)
End Sub
(You can substitute any Pen
for Pens.Black
, of course.)
Upvotes: 8