.NET MAUI コントロール
非連結モード
コントロール > FlexGrid > 非連結モード

The FlexGrid control is designed to work with various data sources and collections such as ObservableCollection and DataCollection to leverage its full capabilities. However, the control is not restricted to data sources and can be used in unbound mode.

The image given below shows an unbound grid populated with cell index notation.

MAUI FlexGrid unbound mode

To create an unbound grid, we created a method named PopulateUnboundGrid and then added rows and columns to the grid using the Add method. The following code illustrates adding rows and columns in a grid and populating it with an indexing notation that specifies a cell by corresponding row and column index by calling the PopulateUnboundGrid method.

C#
コードのコピー
public UnboundMode()
{
    InitializeComponent();

    PopulateUnboundGrid();
}
private void PopulateUnboundGrid()
{
    grid.GridLinesVisibility = GridLinesVisibility.All;

    // 非連結flexGrid に行/列を追加します
    for (int i = 0; i < 10; i++)
    {
        grid.Columns.Add(new GridColumn());
    }
    for (int i = 0; i < 20; i++)
    {
        grid.Rows.Add(new GridRow());
    }
    // 非連結 flexGrid にインデックスなどの値を入力します
    for (int r = 0; r < grid.Rows.Count; r++)
    {
        for (int c = 0; c < grid.Columns.Count; c++)
        {
            grid[r, c] = string.Format("[{0},{1}]", r, c);
        }
    }
}