Graphics.Clear(Color) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
清除整個繪圖表面並填滿指定的背景色。
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)
參數
- color
- Color
繪圖表面的背景色。
範例
以下程式碼範例是為 Windows Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 程式碼會清除繪圖表面的 , Graphics 並將背景色設定為系統定義的青綠色。
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
備註
實際上,此 Clear 方法是用指定顏色的實色畫筆填滿區域。 指定顏色的透明度會被維持。
此方法會清除圖形物件的狀態,當圖形物件無法更新時不應被呼叫。 例如,若在終端伺服器會話的安全桌面上呼叫此 Clear 方法,可能會發生 , ExternalException 導致 Graphics 物件處於不一致狀態。