DrawEllipse OverflowException problem

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
I'm getting an Overflow Exception when drawing multiple ellipses. It's failing on the DrawEllipse method, but the values I'm passing it seem to be acceptable.

VB.NET:
    Private p As Pen = New System.Drawing.Pen(Color.Black, 1)
    Private r As System.Drawing.RectangleF

    Private Sub DrawBlock(ByRef e As System.Windows.Forms.PaintEventArgs, ByVal x As Single, ByVal y As Single)
    .....
	e.Graphics.DrawEllipse(p, r)
    .....
    End Sub

On debugging, it shows :-
VB.NET:
    r {X = -4.0 Y = -4.0 Width = 8.0 Height = 8.0}

The InnerException shows :-

VB.NET:
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawEllipse(Pen pen, Single x, Single y, Single width, Single height)
   at System.Drawing.Graphics.DrawEllipse(Pen pen, RectangleF rect)

It only happens very occasionally, and I can reproduce it.

Any suggestions?
 
Back
Top