ToolStripItem.Paint 活動
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當物品重新繪製時會發生。
public:
event System::Windows::Forms::PaintEventHandler ^ Paint;
public event System.Windows.Forms.PaintEventHandler Paint;
public event System.Windows.Forms.PaintEventHandler? Paint;
member this.Paint : System.Windows.Forms.PaintEventHandler
Public Custom Event Paint As PaintEventHandler
事件類型
範例
以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 Paint 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。
要執行範例程式碼,將它貼到包含繼承自 ToolStripItem的型別實例的專案中,例如 a ToolStripButton 或 ToolStripMenuItem。 接著命名實例 ToolStripItem1 ,並確保事件處理程序與事件 Paint 相關聯。
private void ToolStripItem1_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 ToolStripItem1_Paint(sender as Object, e as PaintEventArgs) _
Handles ToolStripItem1.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
備註
如需處理事件的詳細資訊,請參閱 處理和引發事件。