Infragistics(R) NetAdvantage(R) Windows Forms
UltraDropDown Class
Members  Example  See Also  E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace : UltraDropDown Class

The UltraDropDown control provies a multi-column, grid-like dropdown list in a column of an UltraGrid control.

Syntax

Visual Basic (Declaration) 
Public Class UltraDropDown 
   Inherits UltraDropDownBase
   Implements Infragistics.Shared.IUltraLicensedComponent, Infragistics.Shared.Serialization.ICodeDomSerializable, Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.CalcEngine.IUltraCalcParticipant, Infragistics.Win.IDropDownResizeHandleOwner, Infragistics.Win.IFilterableValueList, Infragistics.Win.IProvideItemImageSize, Infragistics.Win.ISelectionManager, Infragistics.Win.ISupportPresets, Infragistics.Win.IUIElementProvider, Infragistics.Win.IUIElementTextProvider, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement, Infragistics.Win.IValidatorClient, Infragistics.Win.IValueList 
C# 
public class UltraDropDown : UltraDropDownBase, Infragistics.Shared.IUltraLicensedComponent, Infragistics.Shared.Serialization.ICodeDomSerializable, Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.CalcEngine.IUltraCalcParticipant, Infragistics.Win.IDropDownResizeHandleOwner, Infragistics.Win.IFilterableValueList, Infragistics.Win.IProvideItemImageSize, Infragistics.Win.ISelectionManager, Infragistics.Win.ISupportPresets, Infragistics.Win.IUIElementProvider, Infragistics.Win.IUIElementTextProvider, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement, Infragistics.Win.IValidatorClient, Infragistics.Win.IValueList  

Example

Following code initializes an UltraDropDown. It shows how you can change the order of columns, hide columns, sort items among other things.

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.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraDropDown1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraDropDown1.InitializeLayout

      ' Set the scroll style to immediate so when the user scrolls the drop down 
      ' using scroll thumb, rows get scrolled imediately.
      e.Layout.ScrollStyle = ScrollStyle.Immediate

      ' Change the order in which columns get displayed in the UltraDropDown.
      e.Layout.Bands(0).Columns("ProductID").Header.VisiblePosition = 0
      e.Layout.Bands(0).Columns("ProductName").Header.VisiblePosition = 1

      ' Hide columns you don't want shown.
      e.Layout.Bands(0).Columns("UnitsOnOrder").Hidden = True

      ' Sort the items in the drop down by ProductName column.
      e.Layout.Bands(0).SortedColumns.Clear()
      e.Layout.Bands(0).SortedColumns.Add("ProductName", False)

      ' Set the border style of the drop down.
      e.Layout.BorderStyle = UIElementBorderStyle.Solid

  End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraDropDown1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{

	// Set the scroll style to immediate so when the user scrolls the drop down 
	// using scroll thumb, rows get scrolled imediately.
	e.Layout.ScrollStyle = ScrollStyle.Immediate;

	// Change the order in which columns get displayed in the UltraDropDown.
	e.Layout.Bands[0].Columns["ProductID"].Header.VisiblePosition = 0;
	e.Layout.Bands[0].Columns["ProductName"].Header.VisiblePosition = 1;

	// Hide columns you don't want shown.
	e.Layout.Bands[0].Columns["UnitsOnOrder"].Hidden = true;

	// Sort the items in the drop down by ProductName column.
	e.Layout.Bands[0].SortedColumns.Clear( );
	e.Layout.Bands[0].SortedColumns.Add( "ProductName", false );

	// Set the border style of the drop down.
	e.Layout.BorderStyle = UIElementBorderStyle.Solid;	
		
}

Remarks

To attach an UltraDropDown to a grid, use the UltraGridColumn.ValueList property of the UltraGridColumn, or the UltraGridCell.ValueList property of an UltraGridCell.

The UltraDropDown is populated by binding it to a data source, just like the UltraGrid. So use the UltraGridBase.SetDataBinding method, or the UltraGridBase.DataSource and UltraGridBase.DataMember properties.

Be sure to set the UltraDropDownBase.ValueMember property to determine which column in the dropdown is associated with the grid cell.

Optionally, you may also want to set the UltraDropDownBase.DisplayMember property to display more user-friendly text, instead of displaying the value.

Note that the UltraDropDown control requires a container (such as a Form or UserControl) in order to function properly. Placing the control on a form (or UserControl) at design-time is sufficient for this, but if the control is created at run-time in code, be sure to add the UltraDropDown to the form's (or UserControl's) Controls collection.

See Also