RichTextBox.Protected 事件

定義

發生於使用者嘗試修改控制項中保護的文字時。

public:
 event EventHandler ^ Protected;
public event EventHandler Protected;
public event EventHandler? Protected;
member this.Protected : EventHandler 
Public Custom Event Protected As EventHandler 

事件類型

範例

下列程式碼範例示範如何使用這個成員。 在此範例中,事件處理常式會報告事件的發生次數 Protected 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼入包含名為 RichTextBox1 之類型 RichTextBox 實例的專案。 然後,確定事件處理常式與 事件相關聯 Protected

private void RichTextBox1_Protected(Object sender, EventArgs e) {

   MessageBox.Show("You are in the RichTextBox.Protected event.");
}
Private Sub RichTextBox1_Protected(sender as Object, e as EventArgs) _ 
     Handles RichTextBox1.Protected

   MessageBox.Show("You are in the RichTextBox.Protected event.")

End Sub

備註

您可以在應用程式中建立此事件的事件處理常式,以判斷使用者何時嘗試修改控制項中標示為受保護的文字。 事件處理常式可用來通知使用者使用者嘗試修改的文字受到保護,或顯示對話方塊,讓使用者對文字進行適當的變更。 例如,如果受保護的區域是日期,您可以顯示對話方塊,讓使用者選擇可套用至控制項文字的日期。

如需如何處理事件的詳細資訊,請參閱 處理和引發事件

適用於