Version

UltraGridColumnChooser Class

This control allows the user to select which columns to display in an UltraGrid. It displays the list of columns that the user can hide or unhide from the UltraGrid.
Syntax
'Declaration
 
Public Class UltraGridColumnChooser 
   Inherits System.Windows.Forms.Control
public class UltraGridColumnChooser : System.Windows.Forms.Control 
Remarks

UltraGridColumnChooser allows the user to select which columns to display in an UltraGrid. It displays the list of columns that the user can hide or unhide from the UltraGrid.

ColumnChooserDialog embeds this control inside of it. Typically you would display the ColumnChooserDialog to make use of this control. Use the UltraGridBase.ShowColumnChooser method of the UltraGrid to display the column chooser dialog. You can also embed this control inside your own custom dialog.

To associate an UltraGrid with a UltraGridColumnChooser set its SourceGrid property. UltraGridColumnChooser will display the columns of that grid. If your grid has multiple bands then you can specify a particular band whose columns to display by using CurrentBand property. The UltraGridColumnChooser can also display columns of multiple bands at the same time. It also exposes an user interface that lets the user select the band whose columns to display. These two aspects can be controlled using the MultipleBandSupport property.

UltraGridColumnChooser has two main modes of operation. Style property specifies which mode is used.

HiddenColumnsOnly mode displays the columns that are currently hidden in the UltraGrid. In this mode the user can drag the columns between the UltraGrid and the Column Chooser to hide or unhide them.

AllColumnsWithCheckBoxes mode displays all the columns, hidden or otherwise, in the column chooser. There is a checkbox next to each column which the user can use to hide or unhide columns. This mode also offers the same drag and drop capability as the HiddenColumnsOnly option.

AllColumnsAndChildBandsWithCheckBoxes mode behaves the same as AllColumnsWithCheckBoxes except that it also lets the user hide or unhide child bands. Each child band displays a check box next to it, just like the columns that the user can use to hide or unhide the child band. AllColumnsAndChildBandsWithCheckBoxes is the default column chooser style.

Various appearance related aspects can be controlled by the DisplayLayout property. For example, the BackColor of the column chooser can be set using the UltraGridColumnChooser.DisplayLayout.Appearance.BackColor. By default the column chooser syncrhonizes its appearance with the source grid. You can prevent the column chooser from doing this by setting the SyncLookWithSourceGrid property to false. This way you can specify appearance that's different from the source grid.

Example
The following code shows properties, events and methods related to the Column Chooser functionality.

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.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout
        ' UltraGrid has a built-in ui for displaying column chooser dialog. To enable
        ' the ui enable the row selectors and set the RowSelectorHeaderStyle to 
        ' ColumnChooserButton.
        e.Layout.Override.RowSelectors = DefaultableBoolean.True
        e.Layout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton

        ' You can exclude a column from the column chooser by setting the ExcludeFromColumnChooser
        ' property to True. This will prevent the user from hiding or unhiding the column.
        e.Layout.Bands(0).Columns("CustomerID").ExcludeFromColumnChooser = ExcludeFromColumnChooser.True

        ' ExcludeFromColumnChooser is also exposed on the band object. So you can exlude a whole
        ' band from the column chooser.
        e.Layout.Bands(1).ExcludeFromColumnChooser = ExcludeFromColumnChooser.True

        ' ColumnChooserCaption property lets you display a different caption in the column
        ' chooser than in the UltraGrid.
        e.Layout.Bands(0).Columns(1).ColumnChooserCaption = "Column Chooser Caption"
    End Sub

    Private Sub UltraGrid1_BeforeColumnChooserDisplayed(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeColumnChooserDisplayedEventArgs) Handles ultraGrid1.BeforeColumnChooserDisplayed
        ' UltraGrid fires BeforeColumnChooserDisplayed event whenever it's about to
        ' display the column chooser dialog, either via the ColumnChooserButton or
        ' when the ShowColumnChooser method is called on the UltraGrid.

        ' You can access the column chooser dialog that will be displayed using the
        ' Dialog property. Here you can change location, size among other settings
        ' of the dialog.
        e.Dialog.Size = New Size(200, 300)

        ' By default UltraGrid retains the column chooser dialog instance. You can 
        ' set the DisposeOnClose to True to cause the UltraGrid to dispose the dialog 
        ' when it's closed by the user.
        e.Dialog.DisposeOnClose = DefaultableBoolean.True

        ' You can use the ColumnChooserControl property of the dialog to access the
        ' column chooser control that actually displays the list of the columns.
        e.Dialog.ColumnChooserControl.MultipleBandSupport = MultipleBandSupport.SingleBandOnly
        e.Dialog.ColumnChooserControl.Style = ColumnChooserStyle.AllColumnsWithCheckBoxes

        ' By default column chooser attempts to look similar to the source grid whose
        ' columns are being displayed in the column chooser. You can set the
        ' SyncLookWithSourceGrid to false to prevent column chooser from doing this
        ' This will also ensure that the column chooser won't override your appearance
        ' settings.
        e.Dialog.ColumnChooserControl.SyncLookWithSourceGrid = False
        e.Dialog.ColumnChooserControl.DisplayLayout.Appearance.BackColor = SystemColors.Window
    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
        ' You can display the column chooser dialog in code using one of the many
        ' overloads of ShowColumnChooser method.
        Me.ultraGrid1.ShowColumnChooser()
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
		{
			// UltraGrid has a built-in ui for displaying column chooser dialog. To enable
			// the ui enable the row selectors and set the RowSelectorHeaderStyle to 
			// ColumnChooserButton.
			e.Layout.Override.RowSelectors = DefaultableBoolean.True;
			e.Layout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton;

			// You can exclude a column from the column chooser by setting the ExcludeFromColumnChooser
			// property to True. This will prevent the user from hiding or unhiding the column.
			e.Layout.Bands[0].Columns["CustomerID"].ExcludeFromColumnChooser = ExcludeFromColumnChooser.True;

			// ExcludeFromColumnChooser is also exposed on the band object. So you can exlude a whole
			// band from the column chooser.
			e.Layout.Bands[1].ExcludeFromColumnChooser = ExcludeFromColumnChooser.True;

			// ColumnChooserCaption property lets you display a different caption in the column
			// chooser than in the UltraGrid.
			e.Layout.Bands[0].Columns[1].ColumnChooserCaption = "Column Chooser Caption";
		}

		private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, Infragistics.Win.UltraWinGrid.BeforeColumnChooserDisplayedEventArgs e)
		{
			// UltraGrid fires BeforeColumnChooserDisplayed event whenever it's about to
			// display the column chooser dialog, either via the ColumnChooserButton or
			// when the ShowColumnChooser method is called on the UltraGrid.

			// You can access the column chooser dialog that will be displayed using the
			// Dialog property. Here you can change location, size among other settings
			// of the dialog.
			e.Dialog.Size = new Size( 200, 3500 );

			// By default UltraGrid retains the column chooser dialog instance. You can 
			// set the DisposeOnClose to True to cause the UltraGrid to dispose the dialog 
			// when it's closed by the user.
			e.Dialog.DisposeOnClose = DefaultableBoolean.True;

			// You can use the ColumnChooserControl property of the dialog to access the
			// column chooser control that actually displays the list of the columns.
			e.Dialog.ColumnChooserControl.MultipleBandSupport = MultipleBandSupport.SingleBandOnly;
			e.Dialog.ColumnChooserControl.Style = ColumnChooserStyle.AllColumnsWithCheckBoxes;

			// By default column chooser attempts to look similar to the source grid whose
			// columns are being displayed in the column chooser. You can set the
			// SyncLookWithSourceGrid to false to prevent column chooser from doing this
			// This will also ensure that the column chooser won't override your appearance
			// settings.
			e.Dialog.ColumnChooserControl.SyncLookWithSourceGrid = false;
			e.Dialog.ColumnChooserControl.DisplayLayout.Appearance.BackColor = SystemColors.Window;			
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			// You can display the column chooser dialog in code using one of the many
			// overloads of ShowColumnChooser method.
			this.ultraGrid1.ShowColumnChooser( );
		}
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