Component One Silverlight FlexGrid Tip – 2 (Change Selection mode)

FlexGrid provides a cool feature which allows programmers to control what to select when a user click on a cell.  There are four different selection modes available.

The default behavior

* allows user to select a single single if the user click on a particular cell.

image

* You select multiple cells by holding left mouse and dragging the arrow key.

image

* You can select an entire row by clicking on the row selector

image

* You can select range of rows by holding left click and selecting rows. Other options is to use to select multiple rows by holding Shift key.

image

If you do not like the default behavior, then flex grid does exposes a property to change the default selection mode.

image

Cell:

As the name suggests, if you choose Cell Selection mode, you can not select a row, even by clicking on left hand row selector. You can not also select range of cells. It is purely forcing user to select only a one cell at a time.

CellRange:

This is same as Cell selection except, it allows users to select multiple cells or cell range. This selection is always contiguous.

Row:

As the name suggests, when a user click anywhere on a row, the whole row will be selected for you. Only one row will be selected at a time.

RowRange:

Same as Row except, users are allowed to select multiple rows.

You can use CellRange to achieve what RowRange does but not vice versa.

 ListBox:

This is similar to RowRange except, you can select non contiguous rows by holding control key (Ctrl).

image

As you can see I selected first two rows from group 0 and then holding Ctrl key I selected middle two rows of group 1. When I did that, it preserved the first group selection for me. If you would use any other option, the selection must be contiguous.

As you can see non-contiguous cell selection option is not available out of the box. For sure, you can achieve this in code behind with little code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s