Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDraw a hatched ellipse in VB .NET
Keywordsellipse, circle, VB.NET
CategoriesGraphics, VB.NET
 
Create a Graphics object representing the drawing surface. Create a HatchBrush object representing the desired hatch pattern and use the Graphics object's FillEllipse method to fill the ellipse. Then create a new Pen object and use the Graphics object's DrawEllipse method to outline the ellipse.
 
Private Sub btnDrawEllipse_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    btnDrawEllipse.Click
    ' Create a Graphics object representing
    ' the form's drawing surface.
    Dim gr As Graphics = Me.CreateGraphics()

    ' Create a brush representing a "backward
    ' diagonal" fill using blue lines over
    ' a blank background.
    Dim ellipse_brush As New HatchBrush( _
        HatchStyle.BackwardDiagonal, _
        Color.Blue, _
        Me.BackColor)

    ' Fill the ellipse.
    gr.FillEllipse(ellipse_brush, 0, 0, _
        Me.ClientSize.Width, _
        Me.ClientSize.Height)

    ' Make a pen representing a thick red line.
    Dim ellipse_pen As New Pen(Color.Red, 5)

    ' Draw the ellipse.
    gr.DrawEllipse(ellipse_pen, 0, 0, _
        Me.ClientSize.Width, _
        Me.ClientSize.Height)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated