Graphics.Clear(Color) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Clears the entire drawing surface and fills it with the specified background color.
public:
void Clear(System::Drawing::Color color);
public void Clear (System.Drawing.Color color);
member this.Clear : System.Drawing.Color -> unit
Public Sub Clear (color As Color)
Parameters
- color
- Color
The background color of the drawing surface.
Examples
The following code 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 and sets the background color to the system-defined teal color.
private:
void ClearColor( PaintEventArgs^ e )
{
// Clear screen with teal background.
e->Graphics->Clear( Color::Teal );
}
private void ClearColor(PaintEventArgs e)
{
// Clear screen with teal background.
e.Graphics.Clear(Color.Teal);
}
Private Sub ClearColor(ByVal e As PaintEventArgs)
' Clear screen with teal background.
e.Graphics.Clear(Color.Teal)
End Sub
Remarks
Effectively, the Clear method fills an area with a solid color brush of the specified color. The transparency of the specified color is maintained.
This method clears the state of the graphics object and should not be called when the graphics object cannot be updated. For example, if the Clear method is called on a secure desktop in a terminal server session, an ExternalException may occur, leaving the Graphics object in an inconsistent state.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈