My motive is to use some kind of Databinding/Datasource (as it is used in DataGridView, ListView by .Net FrameWork) for my own custom object AdvancedTableEntries
My BindingList Object
public class Employee
{
public string Name{get;set;}
public int PayrollRollNo{get;set;}
public Address CurrentAddress
}
My Custom Object as end result
public class AdvancedTableEntries
{
public AdvancedTableEntries(List<AdvancedTableColumn> columns, List<AdvancedTableCell[]> tableEntries)
{
Columns = columns;
TableEntries = tableEntries;
int width = tableEntries.First().Length;
if (!width.Equals(columns.Count)) throw new System.ArgumentException("Report Entry Column and Datacolumn size doesnot match", "EntriesData");
}
public List<AdvancedTableColumn> Columns { get; private set; }
public List<AdvancedTableCell[]> TableEntries { get; private set; }
}
//Expected Table result as :
Name PayRollNo
John 12345
Harry 4567
Trumph 0000
How method GetTableEntries() will get expected result above ?
class CustomTable : : AdvancedTable
{
IList<Employee> EmployeeItems;
public CustomTable(IList<Employee> items)
{
EmployeeItems = items;
}
public override void CreateDefaultColumns()
{
Columns.Add(new AdvancedTableColumn
{
Visible = true,
DataPropertyName = "Name",
FillWeight = 2,
Merging = true,
});
Columns.Add(new AdvancedTableColumn
{
Visible = false,
HeaderText = Localization.Common.Name,
DataPropertyName = "PayrollRollNo",
FillWeight = 2,
SomeFancyFunction = delegate (object item)
{
var item2 = item as Employee;
return some fancy things...
}
});
}
public override AdvancedTableEntries GetTableEntries()
{
//How to get entries as comparing "DataPropertyName"?and do something like this:
List<AdvancedTableCell[]> tableEntries.DataSource= EmployeeItems
AdvancedTableEntries
}
}
Aucun commentaire:
Enregistrer un commentaire