Professional UI Solutions
Site Map   /  Register
 
 
 

Selection and Focus

How to control focus in the grid?

The Elegant Grid gives you full control over the focus. The grid control's FocusedCell property allows you to get or set the cell which is focused at the moment. The FocusedCellColumn property gets or sets the column that specifies the focused cell in the focused row. You can get or set the focused row by using the FocusedRowIndex property. The FocusedCellChanged event may also be helpful.

The bound grid control (the BoundGridControl class) provides some additional functionality for managing the focus. You can get or set the data item (in the data source) displayed in the focused row by using the FocusedDataSourceItem property. The FocusedDataSourceItemIndexChanged event allows you to track changes of the currently focused data bound row. There are also two auxiliary read-only properties provided to ease access to the bound data displayed in the focused cell: FocusedCellDataValue and FocusedCellDisplayValue. The first property returns the focused cell data value and the second one returns the focused cell display value.

For the unbound grid control (the UnBoundGridControl class), you can use the FocusedRow property gets or sets the focused Row object.

How to enable the full-row focus?

Just set the FullRowFocus boolean property of the grid control to true.

How to get all selected items in the grid?

When working with the bound grid (the BoundGridControl class), you can get all selected data source items by using the SelectedDataSourceItems property. It returns an array of objects if there is more than one item selected. When one item is selected, the property returns only this item.

If you use the unbound grid (the UnBoundGridControl class), the SelectedRows property gets the array of all selected row objects.

Additionally you can get an array that contains the indexes of the selected rows by using the SelectedTtemIndices read-only property. This property can be used both for the bound and unbound grid controls.

How to make selected items look like inactive when the grid is unfocused?

Simply set the ShowSelectionAlways property of the grid control to true.

How to set selection in the grid?

Use the SetDataSourceItemSelection method if you use the bound grid control. It takes two arguments: a data source item and a boolean flag. The latter indicates whether to select or deselect the row bound to this data source item.

The two similar methods for the unbound grid control are SetItemSelection and SetRowSelection. These methods allow you to control the selection by row index and by row instance.

You can use the ClearSelection method to deselect all the rows.


If you have any questions, please visit our forum or contact our technical support team at support@prof-uis.com.