How to use column chooser feature in Infragistics Wingrid


This code shows how to use the column chooser functionality to display a dialog similar to Microsoft Outlook's field chooser where the user can choose columns to display in the Wingrid.

How to use column chooser feature in Infragistics Wingrid :



This code demonstrates using the Column Chooser functionality to display a dialog similar to Microsoft Outlook's Field Chooser where the user can choose columns to display in the WinGrid.

Now, lets start with the step by step process of how we can achieve the same

1. Add using/imports directives
VB:

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


C#:

using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;


2. The WinGrid has in-built RowSelectorheaderstyle property to choose the column button which will display a button in the row selector area. You can change the appearance of it by RowSelectorHeaderAppearance property.

VB:

' Set the RowSelectorHeaderStyle property to ColumnChooserButton.
Me.UltraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle = _
RowSelectorHeaderStyle.ColumnChooserButton

' Enable the RowSelectors.
Me.UltraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True

' If you want to change the BackColor of the button then you need to
' set the ThemedElementAlpha property to Transparent otherwise BackColor setting won't be ' honored.
Me.UltraGrid1.DisplayLayout.Override.RowSelectorHeaderAppearance.ThemedElementAlpha = Alpha.Transparent
Me.UltraGrid1.DisplayLayout.Override.RowSelectorHeaderAppearance.BackColor = Color.Blue


C#:

// Set the RowSelectorHeaderStyle to ColumnChooserButton.
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle =
RowSelectorHeaderStyle.ColumnChooserButton;

// Enable the RowSelectors.
this.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;

// If you want to change the BackColor of the button then you need to
//set the ThemedElementAlpha property to Transparent otherwise BackColor setting won't be //honored.
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderAppearance.ThemedElementAlpha = Alpha.Transparent;
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderAppearance.BackColor = Color.Blue;


3. You can also have your own user interface for displaying the column chooser. UltraGridColumnChooser is derived from .NET Control class. It displays list of columns & implements drag-n-drop functionality. ColumnChooserDialog derives from .NET Form class. It simply embeds UltragridColumnChooser inset it.

The following code demonstrates how to display column chooser dialog.

Visual Basic:

' Create an instance of the ColumnChooserDialog.
Dim dlg As ColumnChooserDialog = New ColumnChooserDialog()

dlg.Owner = Me

Dim cc As UltraGridColumnChooser = dlg.ColumnChooserControl

' Associate a WinGrid to the column chooser.
cc.SourceGrid = Me.UltraGrid1

cc.CurrentBand = Me.UltraGrid1.DisplayLayout.Bands(0)

cc.Style = ColumnChooserStyle.AllColumnsWithCheckBoxes
cc.MultipleBandSupport = MultipleBandSupport.SingleBandOnly

' Set location, size etc...
dlg.Size = New Size(150, 300)

dlg.Show()


C#:

// Create an instance of the ColumnChooserDialog.
ColumnChooserDialog dlg = new ColumnChooserDialog( );

dlg.Owner = this;

UltraGridColumnChooser cc = dlg.ColumnChooserControl;

// Associate a WinGrid to the column chooser.
cc.SourceGrid = this.ultraGrid1;

cc.CurrentBand = this.ultraGrid1.DisplayLayout.Bands[0];

cc.Style = ColumnChooserStyle.AllColumnsAndChildBandsWithCheckBoxes;
cc.MultipleBandSupport = MultipleBandSupport.SingleBandOnly;

// Set location, size etc...
dlg.Size = new Size( 150, 300 );

dlg.Show( );


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: