Skip to content
Radu Martin edited this page Apr 15, 2017 · 18 revisions

These extenders simplify the work with data-bound in WinForms.

Usage the DataGridView:
var tbl1 = CreateAndLoadDataTable();
...
gridView.GenerateColumns(DataSource, 
    new ColumnDataDescriptor("Header#1", tbl1.Column1),
    new ColumnDataDescriptor("Header#2", tbl1.Column2),
    new ColumnDataDescriptor("Header#3", tbl1.Column3, FillWeight: 100));
gridView.PrepareStyleForEditingData();
gridView.AddDataRowStateDrawingInRowHeaders();
Usage the FlowLayoutPanel:
layoutPanel.GenerateGroups(DataSource, 
    new GroupDataDescriptor("GroupName#1",
      new FieldDataDescriptor("Header#1", tbl1.Column1),
      new FieldDataDescriptor("Header#2", tbl1.Column2)),
    new GroupDataDescriptor("GroupName#2",
      new FieldDataDescriptor("Header#3", tbl1.Column3)));
Usage the TableLayoutPanel:
layoutPanel.GenerateFields(DataSource, 
    new GroupDataDescriptor("GroupName",
      new FieldDataDescriptor("Header#1", tbl1.Column1),
      new FieldDataDescriptor("Header#2", tbl1.Column2)));

Supported .NET Frameworks

DataViewExtenders use special things that were introduced in .NET Framework 4.0:

  • Extension Methods (introduced in .NET Framework 3.5)
  • String.IsNullOrWhiteSpace method
  • Tuple Class