FlexGrid の SelectionMode プロパティを使用すると、その値を Row、Cell、CellRange、または RowRange に設定することで、セルの選択モードを定義できます。また、selectionMode を None(デフォルト値)に設定して、選択を無効にすることもできます。
次の図は、SelectionMode プロパティを Row に設定した後の FlexGrid を示しています。
次のコード例は、FlexGrid で選択モードを選ぶ方法を示します。例では、「列の定義」セクションで作成したサンプルを使用します。
C# |
コードのコピー
|
---|---|
grid.SelectionMode = GridSelectionMode.Row; |
また、SelectionMode プロパティは、FlexGrid コントロールからの行、セル、セル範囲、または行範囲の削除がどのように機能するかを制御して指示します。
The selection menu contains common actions such as, editing, selecting, and deleting text. In FlexGrid, selection menu is enabled by default. However, you can disable it by setting the ShowSelectionMenu property to false. In desktop applications, you can activate the selection menu with a right click over a cell or by left clicking. In mobile applications, you can activate selection menu with a long press on a cell or tapping the row header. Also, it supports custom menu actions, in case you want custom actions for the selection menu, you need to set a handler for the CreateSelectionMenu event.
Use the following code snippet to create custom action for the selection menu.
C# |
コードのコピー
|
---|---|
grid.CreatingSelectionMenu += Grid_CreatingSelectionMenu; private void Grid_CreatingSelectionMenu(object sender, GridSelectionMenuEventArgs e) { e.Menu.Items.Add(new GridMenuItem("Clear", () => Clear(e))); } public void Clear(GridSelectionMenuEventArgs e) { for (int c = e.CellRange.Column; c <= e.CellRange.Column2; c++) { for (int r = e.CellRange.Row; r <= e.CellRange.Row2; r++) { grid[r, c] = null; } } } return grid; |