'宣言 Protected Overridable Sub OnBeforeDropDown( _ ByVal e As CancelEventArgs _ )
protected virtual void OnBeforeDropDown( CancelEventArgs e )
イベントが発生すると、デリゲートを通じてイベント ハンドラーが呼び出されます。
OnBeforeDropDown メソッドを使用すれば、デリゲートを関連付けなくても、派生クラスでイベントを処理できます。これは、派生クラスでイベントを処理する際によく用いられる手法です。
継承時の注意: 派生クラスで OnBeforeDropDown をオーバーライドする場合は、登録されたデリゲートがイベントを受信できるようにするため、必ず基本クラスの OnBeforeDropDown メソッドを呼び出してください。
Private Sub UltraCalendarCombo1_BeforeDropDown(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ultraCalendarCombo1.BeforeDropDown ' The BeforeDropDown event is a "cancelable" event, ' which means that the action to which it corresponds can be ' prevented from happening by canceling the event. ' ' Canceling an event is very simple - just set the 'Cancel' ' property of the event arguments to true. The action will then ' be prevented from happening, and the corresponding "After" ' event will not fire. ' Disallow the displaying of the dropdown calendar for weekend ' days by canceling the event if the current date is a Saturday ' or Sunday If (DateTime.Today.DayOfWeek = System.DayOfWeek.Saturday Or _ DateTime.Today.DayOfWeek = System.DayOfWeek.Sunday) Then e.Cancel = True End If End Sub
private void ultraCalendarCombo1_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs e) { // The BeforeDropDown event is a "cancelable" event, // which means that the action to which it corresponds can be // prevented from happening by canceling the event. // // Canceling an event is very simple - just set the 'Cancel' // property of the event arguments to true. The action will then // be prevented from happening, and the corresponding "After" // event will not fire. // Disallow the displaying of the dropdown calendar for weekend // days by canceling the event if the current date is a Saturday // or Sunday if ( DateTime.Today.DayOfWeek == System.DayOfWeek.Saturday || DateTime.Today.DayOfWeek == System.DayOfWeek.Sunday ) e.Cancel = true; }