True DBGrid for WinForms | ComponentOne
In This Topic
    Data Binding
    In This Topic

    True DBGrid for WinForms can universally bind to any .NET data source. Requiring minimal or no coding at all, the TrueDBGrid control can create a fully-navigational database browser in just seconds. True DBGrid fully supports data binding to ADO.NET objects such as DataTable, DataView and DataSet objects. To associate a True DBGrid for WinForms control with an ADO.NET or DataObjects for WinForms data source, set the DataSource property of the grid to a DataSet on the same form. If the DataSet contains multiple tables, you can select a table name in the DataMember property combo box. The DataSource and DataMember properties can be set both through code, and through Visual Studio's Properties window. This is all that is required to make True DBGrid for WinForms fully aware of the database or DataTable in your application.

    Preserve Grid Layout

    If the DataSource is reset through code, it will show all of the data in the grid and will not keep the initial layout created with the Designer. You can ensure that the grid layout remains the same as designed, that is, preserve the grid layout by using the SetDataBinding method with the HoldFields parameter set to True. For example:

    C#
    Copy Code
    // Bind grid at runtime
    c1TrueDBGrid1.SetDataBinding(dt, "", true);
    
    Note: WinForms .NET6 Edition does not include rich design-time support yet. We will enhance it in future releases.