Version

OnBeforeDropDown Method (UltraCalendarCombo)

Raises the BeforeDropDown event before the DropDown has been displayed.
Syntax
'Declaration
 
Protected Overridable Sub OnBeforeDropDown( _
   ByVal e As CancelEventArgs _
) 
protected virtual void OnBeforeDropDown( 
   CancelEventArgs e
)

Parameters

e
A System.ComponentModel.CancelEventArgs that provides data for the event.
Remarks

Raising an event invokes the event handler through a delegate.

The OnBeforeDropDown method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors: When overriding OnBeforeDropDown in a derived class, be sure to call the base class's OnBeforeDropDown method so that registered delegates receive the event.

Example
This example prevents the dropdown from being displayed when the current day is a Saturday or Sunday by setting the Cancel property of the event arguments to true.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also