G
Guest
Hi,
I want to create a datatable that contains columns of a custom type. The
reason is I want these columns to sort properly when bound to datagrid or
similar. An example would be a date with format "MM/YY", this is added to the
datatable as a string. I then receieve this data and re-create the datatable
with appropriately typed columns, so if I know the data is really an int then
I will add a datacolumn of type int. However for these types "MM/YY" etc I
will need a custom type. How can I make this custom type sort correctly?
I know I can implement IComparable on my type but this would require me to
re-add the data as well something like row[0] = new MyCustomType("01/01").
This doesn't seem a good way.
I want to create a datatable that contains columns of a custom type. The
reason is I want these columns to sort properly when bound to datagrid or
similar. An example would be a date with format "MM/YY", this is added to the
datatable as a string. I then receieve this data and re-create the datatable
with appropriately typed columns, so if I know the data is really an int then
I will add a datacolumn of type int. However for these types "MM/YY" etc I
will need a custom type. How can I make this custom type sort correctly?
I know I can implement IComparable on my type but this would require me to
re-add the data as well something like row[0] = new MyCustomType("01/01").
This doesn't seem a good way.