473,395 Members | 1,530 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.

Clearing the window

Hello,

I'm drawing to the window and want to then clear it to the standard
background colour.
However I get errors when trying either of the following:
Graphics g = CreateGraphics();
g.Clear(Parent.BackColor);
g.FillRectangle(new SolidBrush(Parent.BackColor), 0, 0, 600, 600);

Can anyone please help?

James Round

Nov 17 '05 #1
1 1666
James,

The way that you are going about it is wrong. What you want to do is
override the OnPaint method so that it will draw your shape, or, clear the
panel, based on state that you set in your form.

For example, I would have a boolean field indicating whether or not to
paint the shape or not.

Then, in your OnPaint method (after you call the base method
implementation), you would paint your shape.

Also, you might want to use the using statement when constructing the
Brush. If you don't, then you will leak resources.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James" <c_********@yahoo.co.uk> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hello,

I'm drawing to the window and want to then clear it to the standard
background colour.
However I get errors when trying either of the following:
Graphics g = CreateGraphics();
g.Clear(Parent.BackColor);
g.FillRectangle(new SolidBrush(Parent.BackColor), 0, 0, 600, 600);

Can anyone please help?

James Round

Nov 17 '05 #2

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

Similar topics

3
by: Miki Tebeka | last post by:
Hello All, I'd like to bind <CTRL+L> so that it will clear IDLE's screen (in the interactive prompt). Any pointers/suggetions? Thanks. Miki
4
by: Ishwor | last post by:
Hi i use IDLE to code Python in my machine. What i haven't been able to do is call an in-built function called clear()/cls()/clr() because it mightn't exist. so what i did is coded my own function...
1
by: Jacek | last post by:
Hi. I have some problem. Im not sure if this is problem with asp or maybe with iis. I have a form like this - file (file1.asp) <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY>...
7
by: Ian Watts | last post by:
Hi I am designing a website for a local school, and I have knocked up a quick prototype for them to look at. http://www.ianwatts.info/schoolweb/ ...
5
by: phickman | last post by:
Hi all. After several searches using Google, I had just about given up on finding a way to clear the console Window. After spending the past week learning assembly language and writing a small...
1
by: raghavendra | last post by:
Hi, i am facing problem clearing screen in console application. As, in C++ we have clrscr(); Is? their any similar type of function is avaliable.. Raghavendra...
1
by: srinivas | last post by:
Hi I'm having a asp.net page.When i'm clicking on the Logout hyperlink i want to close the window and clear the session. Actually i have taken LinkButton control and written a javascript function...
65
by: Leslie Kis-Adam | last post by:
Hi everyone! Does anyone know, if it is possible to clear the screen in ANSI C? If it is,then how? Any help would be appreciated. Laszlo Kis-Adam <dfighter_AT-NOSPAM_freemail.hu
3
by: Zytan | last post by:
The Immediate Window is filled with debugging output from previous runs. Besides manually right clicking and clearing it, is there a programmatic way of doing this? Should I create and use a...
8
by: HowardChr | last post by:
Is there a way to code a command button on a form that will clear all "-1" Yes/No fields on a table to show as "0"? I tried to type in: "update "InputH- 1" Set Chooser = 0", but am getting an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.