PaintEventArgs.ClipRectangle 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
這樣就能拿到要上色的長方形。
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 Button 或 ComboBox。 接著命名實例 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