I have a simple array of F # entries of the following type (or some minor variations based on system types):
type Transaction= { date: DateTime; amount: float; mutable details: string }
I would like to display them in a DataGridView control in Winforms, including support for modifying content and adding or removing rows / records. Binding a DataViewGrid to an array of records does not seem to allow rows to be added / removed (or should I do it wrong?). However, DataTable structures are better suited for this purpose. Creating a DataTable of the specified type seems to be consistent with the original type of the record, for example.
let dataTable = new DataTable() dataTable.Columns.Add("date", typeof<DateTime>) |> ignore dataTable.Columns.Add("amount", typeof<float>) |> ignore dataTable.Columns.Add("details", typeof<string>) |> ignore)
So, I wonder if there is an existing system function for converting an array of records (for example, of the "transaction array" type) for any type of records based on the types of the system into the corresponding DataTable and vice versa? If there is no such function, how can this be done in a concise form?
source share