$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Component
Bind GridView C#.NET control to hierarchical data in Windows Forms applications
Home > WinForms UI Controls > User Manual > One to More Grid Relations in C#

Bind GridView to Hierarchical with One to Many Relations

Kettic DataGridView is capable of binding to a hierarchy data source containing one to many relations. And the GridView provides the support of showing hierarchical data to an arbitrary number of levels and establishing the hierarchical at either run time or design time. The GridView control allows users generate hierarchical data automatically at runtime as well as create hierarchical data in C# code for Windows Forms application.

Bind GridView to Hierarchy Data with single to Multiple Relations

The Kettic GridView allows users bind the GridView control to a hierarchy data source that has one to many relations. To create the hierarchy data, we must finish these steps: binding GridView to a data source like a DataTable first, adding two or more child templates, and then adding relations to connect the child templates with the master template. The following are the C# code that shows how to create hierarchy of one to many relations.

Format Tabs to Hierarchy Data

When we want to add custom text to the tabs of the child views to replace that of the template caption, we can use the formatting events, the FormatCellView, included in the Kettic GridView. The FormatCellView event allows users to access to the detail cell containing the complete Kettic PageViewElement, from which you can customize the text of each tab separately. The following C# code demonstrates how to apply the custom text to show the count of the rows in each view.

void ketticGridView1_FormatCellView (object sender, FormatCellEventArgs e)
{
GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
if (detailCell != null)
{
for (int i = 0; i < detailCell.PageViewElement.Items.Count; i++)
{
GridViewInfo info = (GridViewInfo)detailCell.PageViewElement.Items[i].Tag;
detailCell.PageViewElement.Items[i].Text = string.Format("{0}, Rows={1}", info.ViewTemplate.Caption, info.Rows.Count.ToString());
}
}
}
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