473,395 Members | 1,335 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,395 software developers and data experts.

Erasing rectangle drawn with DrawRectangle

Dan
I want to use Graphics.DrawRectangle to draw a rectangle at a position on the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?

Thanks...

Dan
Dec 22 '05 #1
2 3348
Dan wrote:
I want to use Graphics.DrawRectangle to draw a rectangle at a position on the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?

Thanks...

Dan

If you force the background object (form, control, etc) to repaint
itself. You can use the invalidate method I believe.

Chris
Dec 22 '05 #2
> I want to use Graphics.DrawRectangle to draw a rectangle at a position on
the
screen, and then a few seconds later, erase it. How do you erase a rectangle
that you just drew (without affecting the original background of the
window(s) behind the rectangle)?


Try ControlPaint.DrawReversibleFrame. Call it once to draw, call it again
with the same args to erase. The disadvantage is that you can't precisely
control the rectangle's color.
Dec 22 '05 #3

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

Similar topics

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...
3
by: Colin McGuire | last post by:
Hi there. I have written a small procedure to draw various shapes on things. A bit of it is shown below. Private Sub drawShape(ByVal shapeType As Integer, ByRef g As Graphics) Select Case...
4
by: Colin McGuire | last post by:
Hi, this is a really simple question I have been banging my head on a brick wall over. The program below changes the background colour of a form depending on whether the cursor is inside a...
1
by: Morten Snedker | last post by:
Hey folks, I'm trying to make my own progressbar. The idea (for my test) is a rectangle that is 1/60 filled with a color per second (so after a minute it is all filled). This is what I have...
5
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in 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: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw...
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
I'm drawing text using the DrawString method. I need a way to go back and erase one or more characters. As a first thought it seemed that one way to do it would be to go back to the character(s)...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.