I am in the process of switching over from DataTable to BindingList. I bind the DataTable to the DataGrid object.
Here my dilemma: while I certainly see the advantages of switching over, my circumstances will make it a bit complex and I am wondering whether it is worth it to switch over.
My scenario: I have a DataGrid which displays chemical samples. There are 5 kinds of sample type, where the columns in the grid will differ for each type (and sometimes within the same type based on other parameters). Some columns remain the same, some are present in 3 types, some in 4 etc etc. Not exactly a case of simple inheritance. Currently, I have a DataTable which makes it easy since I can load whichever columns I want without having to have properties for each sample type which is what I will have to do if I use BindingList. But then, BindingList will make it much easier down the road to refer to sample properties.
This is my first experience with this object (BindingList) so any suggestions welcome. From what I know BindingList binds to properties. So if I have:
public class Sample
{
protected string m_seq;
protected string m_id;
protected string m_weight;
protected string m_units;
public Sample()
{
}
public string Seq
{
get { return m_seq; }
set { m_seq = value; }
}
public string Id
{
get { return m_id; }
set { m_id = value; }
}
public string Weight
{
get { return m_weight; }
set { m_weight = value; }
}
public string Units
{
get { return m_units; }
set { m_units = value; }
}
} //end of class
The grid will be bound to the properties of Sample class if I have something like
BindingList samples = new BindingList<Sample>();
Which means I am going to have 6 types of samples, all with properties defined. The final inheritance structure may be complex, so I am wondering whether it is worth it at all. Any feedback is welcome.
I am using c# 2.0; it is a Windows App.