This documentation is archived and is not being maintained.

Graphics.Clear Method

Clears the entire drawing surface and fills it with the specified background color.

[Visual Basic]
Public Sub Clear( _
   ByVal color As Color _
public void Clear(
 Color color
public: void Clear(
 Color color
public function Clear(
   color : Color


Color structure that represents the background color of the drawing surface.

Return Value

This method does not return a value.


[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code clears the drawing surface of the Graphics object and sets the background color to the system-defined teal color.

[Visual Basic] 
Public Sub ClearColor(e As PaintEventArgs)
' Clear screen with teal background.
End Sub
public void ClearColor(PaintEventArgs e)
// Clear screen with teal background.

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Graphics Class | Graphics Members | System.Drawing Namespace