.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to use column chooser feature in Infragistics Wingrid

Posted By:Deepika Haridas       Posted Date: October 27, 2010    Points: 50    Category: General    URL: http://www.dotnetspark.com  

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.
 

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( );


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend