TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chris Bertrand
NA
3
0
Override Paint Method for a PaintBox
May 3 2007 9:38 AM
Hi,
I am trying to write a program where multiple instances of a class will draw themselves onto a PictureBox. (If there is a better control to use then that would be useful to know!). The paint method in the main form looks like :
public
virtual
void
pbWorld_Paint(
object
sender, System.Windows.Forms.PaintEventArgs e)
{...
The override in the class of which multiple instances will occur is :
public
override
void
pbWorld_Paint(
object
sender, System.Windows.Forms.PaintEventArgs e)
{
// Create a local version of the graphics object for the PictureBox.
Graphics g = e.Graphics;
System.Drawing.Pen pen =
new
Pen(System.Drawing.Color.Black, 1);
g.DrawRectangle(pen, posX, posY, 2, 2);
}
What I need the program to do is, everytime a new instance is created, update the main PictureBox with the new object, and then everytime the position of that object changes, update the area around the object (so as not to redraw the whole screen). I assume that I need to create a specific event for this and link it to the overridden paint method?!
I hope I have included enough info here - if not, just let me know what else you need to know to help me out on this one!
Many thanks,
Bertie.
Reply
Answers (
2
)
need Help on building a GeometryApplication
Simple questions: Placing Pixels on a form