|
|
Title | Use stock pens and brushes in VB .NET |
Keywords | pen, brush, stock, stock pen, stock brush, VB.NET |
Categories | Graphics, VB.NET |
|
|
The program creates a Rectangle to draw later. Then it uses the Graphics object's FillRectangle method to fil the rectangle. It uses the aqua brush provided by the Brushes class. These brushes represent a solid fill using standard colors.
Next the program calls the Graphics object's DrawRectangle method to outline the rectangle. It uses a blue pen provided by the Pens class. These pens are solid and one pixel wide.
|
|
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
Dim rect As New Rectangle(10, 10, _
Me.ClientSize.Width - 20, _
Me.ClientSize.Height - 20)
' Fill a rectangle with a solid Aqua brush.
e.Graphics.FillRectangle(Brushes.Aqua(), rect)
' Outline the rectangle with 1-pixel line.
e.Graphics.DrawRectangle(Pens.Blue(), rect)
End Sub
|
|
|
|
|
|