$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Control
Powerful GridView C#.NET control supports data binding to various data sources
Home > WinForms UI Controls > User Manual > Binding to DataTable in C#

Bind C# GridView to DataTable or DataSet

The Kettic GridView C#.NET component allows users of the GridView control easily binding to database table or dataset. This way of data binding is really easy and requires no complex process. The data binding operation only need the data objects implement one of these interfaces, IList, IEnumarable, or ICollection. Additionally, the powerful data grid control supports out of the box binding to objects in sub directory as well as their properties for customizing.

Bind GridView to Data Table or DataSet in C# project

The Kettic GridView component allows users of the GridView control easily binding to database table or dataset. The following is a guide that shows how to bind the GridView control to a single data table. When we want to binding the GridView to multiple data tables, we can achieve that by referring to hierarchical data binding.
  1. Drag a KetticGridView component from the toolbox and drop on a form in your C#.NET project.
  2. Change the value of the Dock property as Fill to dock the Window to GridView
  3. Open the Properties window of the GridView component on the Form, go to the DataSource property, and open the list by clicking the arrow.
  4. Choose the Add Project Data Source... link to show the Data Source Configuration Wizard. And then select a Data Source Type page in the Wizard, click the Database icon, and hit the Next button.
  5. Choose the New Connection... button in the Choose Your data Connection page to show the Add Connection dialog. And then hit the Change... button to show the Change Data Source dialog.
  6. In the Change Data Source dialog, choose the Microsoft Access Database File data source. After finishing it, hit the OK button to close the dialog.
  7. When the Add Connection dialog display, we can choose the Database File Name Browse button and find the database table, NWind.mdb, included in the GridView control, which is under the path: \KetticGridViewWinForms\DataSamples. Close the dialog by hitting the OK button.
  8. Choose the Categories checkbox in the Choose Your Database Objects page and close the Data Source Configuration Wizard by hitting the Finish button.
  9. Choose the Categories data table from the grid DataSource property in the Properties window. Then the DataSet, BindingSource and TableAdapter objects will be generated for the categories table.
  10. Now we can copy the C# code below, which will iterate all the columns in the grid and calls BestFit() to expand columns for displaying data, and paste them to the Form_Load event handler. After that, debug the C#.NET Windows Forms project to see the result.

private void GuideBindingToDataTableOrDataSet_Load(object sender, EventArgs e)
{
this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
foreach (GridViewDataColumn column in ketticGridView1.Columns)
{
column.BestFit();
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls