-
Fillrectange problem
Hi all,
I am trying to set up a picturebox in a form so i can add small rectangles (points of interest) over a floor plan. I have the following code which does exactly what i want but im having trouble filling the rectangles with solid colour. Heres the code i have:
Code:
Dim MyRect As New Rectangle(e.X, e.Y, 10, 10)
Dim g As Graphics = Me.picShowPicture.CreateGraphics
Dim Pn As Pen = New Pen(Color.Red) 'Create pen from color
Dim Mybrush = New SolidBrush(Color.Red)
points.Add(e.Location) '
For Each p As Point In points
picShowPicture.Invalidate(MyRect)
If ComboBox4.Text = ("Computer") Then
g.DrawRectangle(Pn, MyRect)
'g.FillRectangle(Mybrush, MyRect)
End If
Next
g.Dispose()
Any help gratefully received.
Kev
-
Re: Fillrectange problem
For a start, you shouldn't be calling CreateGraphics at all. You should be doing your drawing in the Paint event handler and using the Graphics object provided by the 'e' parameter.
As for the question, you use FillRectangle to draw a filled rectangle.