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
christian de wet
NA
30
0
PictureBox Transparency background appears Black after Graphics.Clear(Color.Transparent)
Aug 8 2007 5:26 AM
Hello,
I've been struggling with this for quite a while and can't get it fixed. I'm busy with a GIS app. For this I have two PictureBoxes. The first contains all the polygon shapes. the second, I would like to use as a type of overlay over the first, so that I don't need to redraw all the polygons over and over again. When adding the Overlay PictureBox over the First, I can still see the First through the Overlay PictureBox because the Overlay PictureBox has a BackColor of Transparent. But now, the problem: At the moment I have a MouseMove event for the Second PictureBox to draw a rectangular SelectionBox. The code is as follows :
private void Map_MouseMove(object sender, MouseEventArgs e)
{
mouseMoveX = (float)e.X;
mouseMoveY = (float)e.Y;
selectBoxGraphics = overlayBox.CreateGraphics();
if (e.Button == MouseButtons.Left)
{
selectBoxGraphics.Clear(Color.Transparent);
Pen myPen = new Pen(Color.Red, 1.5f);
myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
selectBoxGraphics.DrawRectangle(myPen, GetProperSelectRec());
myPen.Dispose();
}
}
The problem code here is "selectBoxGraphics.Clear(Color.Transparent)". This immediately sets the background of the PictureBox to Black, so I can't see the First PictureBox. Why is this? and How do I fix it?
Any help will be appreciated
Thank you
Nathanael
Reply
Answers (
4
)
A generic error occurred in GDI+.
Bitmap bufferring or clipping? Which is better?