Search code examples
c#winformsdatagridviewdeedle

Bind Deedle Frame to DataGridView


I want to bind a Deedle Frame to a DataGridView.

Creating a data frame:

var rnd = new Random();
var objects = Enumerable.Range(0, 10).Select(i =>
  new { Key = "ID_" + i.ToString(), Number = rnd.Next() });
var dfObjects = Frame.FromRecords(objects);

and then binding it to a DataGridView:

dgv.DataSource = dfObjects;

results in nothing getting displayed.

I have googled for a solution and have not been able to find a relevant answer.

I have tried to convert, the frame, to a 2D array and bind that to the DataGridView, but this is cumbersome and I am assuming there must be a better/simpler way.

The question, therefore, is, what is the appropriate way to bind a Deedle Frame to a DataGridView.


Solution

  • For some reason Visual Studio was not showing the extension methods available on the Frame.

    After I restarted VS I was able to access the extension method .ToDataTable, on the data frame, which serves the purpose of displaying a Frame through a DataGridView, well:

    dgv.DataSource = dfObjects.ToDataTable(new List<string>() { "Index" });