Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I bind multidimensional data to a DataGridView in C# and .NET?

I'm looking to develop an app which features worksheets subclassed from DataGridView. Users can paste (or import) CSV-like data into the worksheet and it will be reflected in a data structure in memory - my first guess would be a 2D array of floats.

DataGridView can be bound to objects with a certain set of interfaces (i.e. IList, IListSource etc.) and so, in theory I could create a class which encapsulates a 2D array and implements one of these interfaces. However, what is puzzling is that the interface specs seem to only cater for 1 dimensional arrays - see IList for example. What is going on?!

Update: From the answers, seems IList caters for lists of objects. Is there a way then to bind a multi-dimensional array of arbitrary size (of floats) to a DataGridView? Or is it ok to use the DataGridView itself as the data structure for storing the floats?

like image 536
Brendan Avatar asked Jan 12 '09 19:01

Brendan


1 Answers

I've done something like this before, here - representing a 2D array in an IList; might be useful.

like image 105
Marc Gravell Avatar answered Sep 25 '22 23:09

Marc Gravell