Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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 _
)
[C#]
public void Clear(
 Color color
);
[C++]
public: void Clear(
 Color color
);
[JScript]
public function Clear(
   color : Color
);

Parameters

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

Return Value

This method does not return a value.

Example

[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.
e.Graphics.Clear(Color.Teal)
End Sub
        
[C#] 
public void ClearColor(PaintEventArgs e)
{
// Clear screen with teal background.
e.Graphics.Clear(Color.Teal);
}
        

[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.

Requirements

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

Show:
© 2015 Microsoft