Version

BeforeDropDown Event (UltraComboEditor)

Fired before the dropdown list is displayed
Syntax
'Declaration
 
Public Event BeforeDropDown As CancelEventHandler
public event CancelEventHandler BeforeDropDown
Event Data

The event handler receives an argument of type CancelEventArgs containing data related to this event. The following CancelEventArgs properties provide information specific to this event.

PropertyDescription
Cancel  
Remarks

The BeforeDropDown event can be canceled; when this happens, the dropdown list is not displayed, and the AfterDropDown event does not fire.

Example
This sample dynamically populates the list portion of the control based on arbitrary criteria.

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 UltraComboEditor1_BeforeDropDown(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles UltraComboEditor1.BeforeDropDown
     
' Modify contents of dropdown, prior to list dropping.
     Me.UltraComboEditor1.Items.Clear()

     If UseEvens() Then
         Me.UltraComboEditor1.Items.Add(1, "One")
         Me.UltraComboEditor1.Items.Add(3, "Three")
         Me.UltraComboEditor1.Items.Add(5, "Five")
         Me.UltraComboEditor1.Items.Add(7, "Seven")
     Else
         Me.UltraComboEditor1.Items.Add(2, "Two")
         Me.UltraComboEditor1.Items.Add(4, "Four")
         Me.UltraComboEditor1.Items.Add(6, "Six")
         Me.UltraComboEditor1.Items.Add(8, "Eight")
     End If

 End Sub

 Private Function UseEvens() As Boolean

     'Returns true or false, based on system time.
     Return (System.DateTime.Now.Millisecond Mod 2) = 0

 End Function
private void ultraComboEditor1_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs e)
{
	
	// Modify contents of dropdown, prior to list dropping.
	this.ultraComboEditor1.Items.Clear();

	if(UseEvens())
	{
		this.ultraComboEditor1.Items.Add(1,"One");
		this.ultraComboEditor1.Items.Add(3,"Three");
		this.ultraComboEditor1.Items.Add(5,"Five");
		this.ultraComboEditor1.Items.Add(7,"Seven");
	}
	else
	{
		this.ultraComboEditor1.Items.Add(2,"Two");
		this.ultraComboEditor1.Items.Add(4,"Four");
		this.ultraComboEditor1.Items.Add(6,"Six");
		this.ultraComboEditor1.Items.Add(8,"Eight");
	}

}

private bool UseEvens()
{
	//Returns true or false, based on system time.
	return (System.DateTime.Now.Millisecond % 2) == 0;				 
}
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