drawing on a picbox from a class  
Author Message
vinnyvinny22





PostPosted: Thu Apr 21 11:54:05 CDT 2005 Top

Visual Basic [VB] >> drawing on a picbox from a class

I have a form with a Picturebox on it. I also have a class that
contains data that I want to graph in the picture box. How do I pass
the PictureBox to a method of the class and have the method draw in the
picture box

in the form I have
Private B As New Box
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
B.Draw(Me.pb) 'pb is the picturebox
End Sub
End Class

here is the class I am building, but the Draw method doesn't work
Class Box
Public Sub Draw(ByVal pb As PictureBox)

Dim e As PaintEventArgs
Dim blackPen As New Pen(Color.Black, 3)
e.Graphics.DrawLine(blackPen, 0, 0, pb.Width, pb.Height)

End Sub
End Class

Can anyone explain to me how to do this?
thanks
kevin

Visual Studio383  
 
 
Bob





PostPosted: Thu Apr 21 11:54:05 CDT 2005 Top

Visual Basic [VB] >> drawing on a picbox from a class See the various articles in the GDI+ FAQ and Windows Forms Tips and Tricks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.







>I have a form with a Picturebox on it. I also have a class that contains
>data that I want to graph in the picture box. How do I pass the PictureBox
>to a method of the class and have the method draw in the picture box
>
> in the form I have
> Private B As New Box
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> B.Draw(Me.pb) 'pb is the picturebox
> End Sub
> End Class
>
> here is the class I am building, but the Draw method doesn't work
> Class Box
> Public Sub Draw(ByVal pb As PictureBox)
>
> Dim e As PaintEventArgs
> Dim blackPen As New Pen(Color.Black, 3)
> e.Graphics.DrawLine(blackPen, 0, 0, pb.Width, pb.Height)
>
> End Sub
> End Class
>
> Can anyone explain to me how to do this?
> thanks
> kevin