Xamarin.iOS のドキュメント
セルの選択
コントロール > FlexGrid > 機能 > セルの選択

FlexGrid の SelectionMode プロパティを使用すると、その値を Row、Cell、CellRange、または RowRange に設定することで、セルの選択モードを定義できます。このプロパティは、GridSelectionMode 列挙体からこれらの値を受け取ります。

次の図は、selectionMode プロパティを Row に設定した後の FlexGrid を示しています。

次のコード例は、FlexGrid で選択モードを選ぶ方法を示します。例では、「クイックスタート」セクションで作成したサンプルを使用します。

CS
コードのコピー
grid.SelectionMode = GridSelectionMode.Row;

また、SelectionMode プロパティは、FlexGrid コントロールからの行、セル、セル範囲、または行範囲の削除がどのように機能するかを制御して指示します。

Selection Menu

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 on a cell. In mobile applications, you can activate selection menu with a long press on a cell or by tapping the row header. You can also add custom actions to the selection menu by setting a handler for 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;