473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Rectangle not visible

I have the following code, which draws a ractangle on a picture box, but the
rectangle does not become visible until I overlay another Window over the
picture box and remove this window. How can I fix this problem?
private static void PictureBox1_paint( object sender, PaintEventArgs e )
{
// Get Graphics Object
Graphics g = e.Graphics;

// Create pen
Pen bluePen = new Pen( Color.Blue, 2 );

// Draw rectangle to screen
g.DrawRectangle( bluePen, 10, 10, 220, 150 );

bluePen.Dispose();
}
Thank You
Peter
Mar 6 '06 #1
3 2714
Hi
It works in Visual Studio 2005!!!
A.Hadi

Mar 6 '06 #2
Hi Peter,

Thanks for your information, it is strange that I can not reproduce the
problem.
I test on both .NET 1.1 and .NET 2.0.
Here is my test steps, you may have a try.
1. Create a new winform application
2. Add a picturebox control
3. set the Dock property to Fill
4. Handle the Paint event and copy/paste the code as you post
// Get Graphics Object
Graphics g = e.Graphics;
// Create pen
Pen bluePen = new Pen(Color.Blue, 2);
// Draw rectangle to screen
g.DrawRectangle(bluePen, 10, 10, 220, 150);
bluePen.Dispose();

Press Ctrl+F5 to run the code, I will the blue rectange on the picture.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 6 '06 #3
I have the following code, which draws a ractangle on a picture box, but the rectangle does not become visible until I overlay another Window over the
picture box and remove this window. How can I fix this problem?


[cut]

Ty this

http://www.bobpowell.net/picturebox.htm

Cheers

Jock
Mar 6 '06 #4

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

Similar topics

15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
2
by: AndrewW | last post by:
Hi I have an application that draws a selection rectangle over a map image. I can get it to work fine in IE and Opera, but not Firefox/Netscape. I've thrown the following small example...
0
by: Stephen Bedford | last post by:
I am developing an application that is primarily keyboard not mouse driven. Navigation is very difficult within some controls (list boxes, radio groups etc) unless the focus rectangle is visible. ...
3
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle...
0
by: Alex Pierson | last post by:
I am using SetROP2 to set the mix mode of a window's rectangle as R2_NOT and rectangle to draw a box around the window in inverse color. My problem is determining whether the current state of the...
2
by: Andy Chen | last post by:
Hi, Now I can get the rectangle to draw, but it seems the rectangle is not visible. The following code is used to draw the rectangle. Hope someone can help. Thanks very much! SolidBrush brush...
1
by: PJ6 | last post by:
I've Googled this but come up short... I have a non-rectangular region that contains a moveable rectangle. I want to restrict the rectangle's movement to have it always fully contained in this...
6
by: A2K | last post by:
Hi, I have made an applicationa in C#(VS 2005), which allows the user to plot and zoom a graph. while zooming, the user drags the mouse to specify a rectangular area, which is then magnified. ...
10
by: kimiraikkonen | last post by:
Hi, If previous post was missing, here's the complete one: I'm trying to draw a rectange on a picturebox image using mouse move event but the problem is that the rectangle selection / drawing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.