PaintEventArgs.ClipRectangle 屬性

定義

這樣就能拿到要上色的長方形。

public:
 property System::Drawing::Rectangle ClipRectangle { System::Drawing::Rectangle get(); };
public System.Drawing.Rectangle ClipRectangle { get; }
member this.ClipRectangle : System.Drawing.Rectangle
Public ReadOnly Property ClipRectangle As Rectangle

屬性值

Rectangle 來作畫的地方。

範例

以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 Control.Paint 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。

要執行範例程式碼,將它貼到包含繼承自 Control的型別實例的專案中,例如 a ButtonComboBox。 接著命名實例 Control1 ,並確保事件處理程序與事件 Control.Paint 相關聯。

private void Control1_Paint(Object sender, PaintEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ClipRectangle", e.ClipRectangle );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Paint Event" );
}
Private Sub Control1_Paint(sender as Object, e as PaintEventArgs) _ 
     Handles Control1.Paint

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ClipRectangle", e.ClipRectangle)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Graphics", e.Graphics)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Paint Event")

End Sub

適用於

另請參閱