Version

Enabling Multiple Row Selection

Purpose

This topic provides a conceptual overview of how to enable multiple row selection in the WinGrid™ ColumnChooser. This feature can be useful in scenarios where the changing the visibility or position of large numbers of columns is an application requirement.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

Contains general information related to using the WinGrid™ Column Chooser feature.

Enabling Muliple Row Selection Overview

Overview

The WinGrid™ ColumnChooser is used to provide a front end through which the user can change the visibility and/or position of the grid’s columns. The chooser can be presented to the user via several different approaches; for example, on a dialog which is displayed when a button in the grid is clicked, or as a standalone control residing on the same form.

The following screen shot shows the column chooser as it appears on the dialog that is displayed when a button in the grid is clicked:

Enabling Multiple Row Selection 1.png

The checkbox on each row depicts the visibility of the corresponding column header; unchecking a row hides the corresponding column. In previous versions, the selection of rows was limited to only one at a time. Because of this, the visibility of only one column at a time could be affected through user interaction. The column chooser also supports column positioning via drag and drop. This action was also restricted to one column at a time in previous versions. A new property has been added to the UltraGridColumnChooser control, MultiSelect Enabled, which switches on multiple row selection, subsequently allowing the visibility or position of any number of columns to be changed in one atomic operation via user interaction.

Preview

The following screenshot shows the same ColumnChooser as above with the MultiSelectEnabled property of the UltraGridColumnChooser control set to true, after clicking the ‘Discontinued’, ‘ProductName’, and ‘ReorderLevel’ rows while pressing the control key, i.e. after a standard extended selection.

ColumnChooser 1.png

Clicking a checkbox on any of the selected rows will change the state for all the selected rows, with the new value being the inverse of the current state of the first row in the selection. For example, if the first row is currently selected, the check state of all rows in the selection is set to Unchecked, thus hiding the three associated columns. Pressing the spacebar has the same effect – the check state for all selected rows is affected, not just the currently active row.Additionally, initiating a drag operation from any of the selected rows causes all of the selected rows to be dragged.

UltraGridColumnChooser Class

UltraGridColumnChooser summary

The following table lists the properties that were added to the UltraGridColumnChooser class to support multiple row selection:

Property Name Property Type Description

Bool

Returns or sets a Boolean value indicating whether multiple row selection is supported. When this property is set to true, the user can change the visibility or position of multiple columns in one atomic operation.

Configuring the column chooser for multiple row selection

Example

The following example demonstrates how to enable multiple row selection on the column chooser using the following property settings of the UltraGridColumnChooser class:

Property Value

true

Which will result in a column chooser which supports multiple row selection:

ColumnChooser 1.png

In C#:

using Infragistics.Win.UltraWinGrid;
// Show the column chooser button in the grid.
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton;
// Handle the BeforeColumnChooserDisplayed event, which fires immediately
// before the ColumnChooser dialog is displayed.
this.ultraGrid1.BeforeColumnChooserDisplayed += new BeforeColumnChooserDisplayedEventHandler(ultraGrid1_BeforeColumnChooserDisplayed);
private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e)
{
 // Set MultiSelectEnabled to true
 e.Dialog.ColumnChooserControl.MultiSelectEnabled = true;
}

In Visual Basic:

Imports Infragistics.Win.UltraWinGrid
' Show the column chooser button in the grid.
Me.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton
' Handle the BeforeColumnChooserDisplayed event, which fires immediately
' before the ColumnChooser dialog is displayed.
AddHandler ultraGrid1.BeforeColumnChooserDisplayed, AddressOf Me.ultraGrid1_BeforeColumnChooserDisplayed
Private Sub ultraGrid1_BeforeColumnChooserDisplayed(sender As Object, e As BeforeColumnChooserDisplayedEventArgs) Handles ultraGrid1.BeforeColumnChooserDisplayed
 ' Set MultiSelectEnabled to true
 e.Dialog.ColumnChooserControl.MultiSelectEnabled = True
End Sub

Related Content

Topics

The following topics provide additional information related to this topic:

Topic Purpose

Contains general information related to using the WinGrid™ Column Chooser feature.