Results 1 to 4 of 4

Thread: how do i code this Me.CreateGraphics.DrawPie

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275

    how do i code this Me.CreateGraphics.DrawPie

    okm how do i code this

    Me.CreateGraphics.DrawPie

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

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Override the OnPaint method.
    Last edited by DevGrp; Oct 27th, 2002 at 12:02 PM.
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275
    dont follow.
    please give some code!

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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.

    VB Code:
    1. 'This will get called each time the form is painted
    2. Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
    3.         Dim g As Graphics = pe.Graphics
    4.         g.DrawPie(Pens.Red, New Rectangle(New Point(10, 30), New Size(90, 90)), 90, 90)
    5. 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.

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim g As Graphics = Me.CreateGraphics()
    3.         g.DrawPie(Pens.Red, New Rectangle(New Point(30, 60), New Size(90, 90)), 90, 90)
    4. 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:

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim g As Graphics = TabControl1.CreateGraphics()
    3.         g.DrawPie(Pens.Red, New Rectangle(New Point(30, 60), New Size(90, 90)), 90, 90)
    4. End Sub
    Dont gain the world and lose your soul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width