473,498 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Nov 21 '05 #1
1 1055
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.

"Kevin" <kb*****@charter.net> wrote in message
news:Tj*****************@fe02.lga...
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1717
by: Nevo | last post by:
I got a newbie question, how do I send input text to appear in picBox when the command button is clicked? thanks for the help
1
2373
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to...
2
12289
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
0
1276
by: borhan | last post by:
I am designing a program in which the user will be drawing, lines, circules and so on, on a paint control which displays an image opened by the user. "It's like there is a map on the picturebox...
2
10316
by: kalp suth via DotNetMonster.com | last post by:
I want to create arrows using lines on a picture in the picture box. On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the...
4
5424
by: Steve | last post by:
I'm a bit baffled. I'm fairly new to VB.NET so maybe I'm missing something. I'm creating a class that has some application-specific methods and properties and one thing I'd like to do is define...
5
3333
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
1
1765
by: lab3terch | last post by:
Imports System.Drawing.Graphics Public Class Form1 Inherits System.Windows.Forms.Form Dim x1, y1, x2, y2 As Integer Dim red, black, blue, green, orange As Color Dim x, y, w, h...
0
863
by: Bram2008 | last post by:
I have 2 picbox which contain lines. And i want to print it with "form.print" or "me.print". The problem is i can print the form, but the lines in picture box is gone or missing. ;). Please help me...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.