ComponentOne FlexGrid for WinForms
In This Topic
    Loading the Data
    In This Topic

    Loading data into an outline grid is exactly the same as loading it into a regular grid. If your data source is available at design time, you can use the Visual Studio Property Window to set the grid's DataSource property and bind the grid to the data without writing any code.

    If the data source is not available at design time, you can set the grid's DataSource property in code. The data binding code typically looks like this:

    To write code in C#

    Copy Code
    public Form1()
        // get data
        var fields = @"
        var sql = string.Format("SELECT {0} FROM Invoices ORDER BY {0}", fields);
        var da = new OleDbDataAdapter(sql, GetConnectionString());
        // bind grid to data
        this._flex.DataSource = _dt;
        // format ExtendedPrice column
        _flex.Cols["ExtendedPrice"].Format = "n2";

    The code uses an OleDbDataAdapter to fill a DataTable with data, thenand then assigns the DataTable to the grid's DataSource property.

    After running this code, you would get the "regular grid" shown in the first image. To turn this regular grid into the outline grid shown in the second image, we need to insert the node rows that make up the outline.

    See Also