I would like to make a (very lightweight) 2-way binding datastore. Values must be accessed via names. I was thinking of using 2 arrays:
public class MyBindingDatastore{
public string[] _names = new string[]{"Field1", "Field2", "Field3"}
public object[] _values = new object[]{ DateTime.Now, "MyValue", 1}
}
First array is used to store field names(always 1 row). Second array( can be also 2D if more than 1 record) represent value matrix. Using GUI widget(Resco detailview or any that support 2-way databinding), I would like to specify:
MyControl.DataMember = "Field1";
MyControl.DataSource = new MyBindingDatastore();
Result of databinding should be properly displayed value from the value array. After a value inside GUI widget is changed, a change must occour in a datastore(value array) too.
Any idea on how to implement that? Or, is it better to use more bloated DataTable class to mimic datatable binding (I believe that DataTable has a lot overhead against array)?