PDA

Click to See Complete Forum and Search --> : how do i code this Me.CreateGraphics.DrawPie


area91
Oct 27th, 2002, 08:58 AM
okm how do i code this

Me.CreateGraphics.DrawPie

sorry i just need to draw a shape..thanks!

DevGrp
Oct 27th, 2002, 10:03 AM
Override the OnPaint method.

area91
Oct 27th, 2002, 11:29 AM
dont follow.
please give some code!

DevGrp
Oct 27th, 2002, 04:58 PM
Ok here ya go.

You are going to have to override the OnPaint Method. Thats the method that gets called when the form paints itself. Here is an example.


'This will get called each time the form is painted
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
Dim g As Graphics = pe.Graphics
g.DrawPie(Pens.Red, New Rectangle(New Point(10, 30), New Size(90, 90)), 90, 90)
End Sub

If you dont want to override the OnPaint Method and you want to draw on the form from a buttonClick, you can do this.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = Me.CreateGraphics()
g.DrawPie(Pens.Red, New Rectangle(New Point(30, 60), New Size(90, 90)), 90, 90)
End Sub

You can do that to any control on your form.
Suppose you wanted to draw on a TabControl on your form. You would do this:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim g As Graphics = TabControl1.CreateGraphics()
g.DrawPie(Pens.Red, New Rectangle(New Point(30, 60), New Size(90, 90)), 90, 90)
End Sub