That's not what I'm looking for.
I have several custom classes and all sorts of implementations beyond the standard Microsoft libraries.
Effectively, I have a descendant of BindingList<T> which i use for most of my lists, and permutation of that descendant which handles dictionaries. All are thread safe, serializable, and support advanced multi-column sorting. Let's just call it MyBindingList<> for reference.
The problem is when I have a class, say MyData which has a Name and Value property on it, fully supporting INotifyPropertyChanged, I can bind MyBindingLIst<MyData> to a DataGridView. I Create the columns, and set the DataGridViewColumn.DataPropertyName = to "Value" and "Name" respectively, and the data shows up, and is manageable as expected from the DataGridView control to the underlying data source.
If however, MyData doesn't have any properties, but is in fact a descendant of MyBindingList<string>, or if it simply has an internal MyBindingList<string> to store the data, there are no "Properties" to bind the individual DataGrdiViewColumn classes to.
Now, the other example for this is the DataTable with the DataRow classes. DataRow does not have a "Name" or "Value" property on it, but somehow, in the BindingContext and CurrencyManager of WinForms, the DGV is able to interpret from the DataTable and DataColumn and DataRow classes the correct row/column information in order to bind the individual cells.
I am looking for that implementation. I know that DataRow is not a "list" class directly. It uses references back to the DataTable and Columns collection to grab the correct Column Data for that row. But that doesn't explain how the binding works between the DataGridView and these classes.
so , for example:
class MyTable : BindingList<MyRow>
{
public BindingList<MyColumn> Columns {get;}
}
class MyColumn {
public string Name {get;set;}
public string Caption {get;set;}
}
class MyRow {
public this [MyColumn column] {get; set;}
public this[int columnIndex] {get;set;}
public this[string columnName] {get;set;}
protected BindingLIst<string> Data {get;}
}
Now, i can create the columns in the DGV from the Columns Property. I can set the MyTable as the data source for the DGV. Now IF MyRow had "properties" on it (like Name, Value, DateOfBirth, etc) i could map those properies directly to the columns via the DataPropertyName on the DataGridViewColumn. But like the DataRow, MyRow lacks this definition, because it is a dynamically created "table" so to speak.
When i use this above model as the datasource for the DataGridView i get a visible row for EACH of the items in MyTable. But all the cells are Blank. Even when the "column name" and DataPropertyName are assigned in the same fashion that it appears in the watch windows from when I'm using a DataTable.
I'm asking given the above descriptors for these classes, what can i implement in the MyTable & MyRow classes in order achieve the same behavior as the DataTable and DataRow. There are no properties to bind on the DataRow class, and yet if there is DataColumn "Name" and a DataColumn "Value" in that DataTable, it shows up perfectly in the grid for each of the DataRow classes found in the provided DataTable. Each DataGridViewRow.DataBoundItem is returns to be a DataRow. The DataColumn's have a DataPropertyName of "Name" and "Value", yet there is still no property to map to on the underlying bound item type of DataRow. How does it achieve this?
I do not care about entity framework, or other sorting aspects, i am asking how the DataTable with DataColumn and DataRow that do not have "bindable properties' end up binding correctly to the DataGridView so i can mimic this behavior.
Thanks
J"SD"a'RR