What I need to do is display a two-dimensional array in a grid -- a matrix with both row and column headers. Both row and column counts vary based on user input. It might be 5X5, or 7X7, or 13X6, whatever. The key issue is that the number of columns varies, as do the column headers. I want to give the grid a list of headers, and have it get its data by row/column index. I would greatly prefer not to use a DataTable to achieve this. Do I need to do this entirely with unbound columns? If so, do I have to loop to set every value in the grid? I know that the grid has to be bound to something, and I am not sure what that would be in this case.
Additionally, I would like to have row headers as well as column headers. Does anybody have any suggestions as to whether/how this can be done?
You cannot use a WinGrid completely unbound, it must have a DataSource.
What I would recommend is that you use an UltraDataSource component as your grid's DataSource in virtual mode. Check out the Virtual Mode sample. Basically, the way it works is that you define the columns in the UltraDataSource and tell it the total number of rows and then you handle events to populate the data which is requested as-needed by the grid.
Hi Mike,
that doesn't quite do it in my case. I have to reproduce the following grid:
Now at the back end I have the following options: Multi dimensional array, dictionary or a list of lists (that last option is actually what I have but I could change it to one of the other two).
The task is obvious: Get that data bound to the grid. Filling the whole thing up manually is the last thing I want to do.
Now surely the UltraGrid will not let me down and be better than the old grid? ;-)
Hi,
I'm not sure I understand what the problem is.
You can bind the grid to any object which implement IList or IBindingList. So you could create your own BindingList<T> of objects of your choice.
You have to define the data structure at some point and then bind an object to the grid that represents that data structure.
I didn't say anything about filling the grid up manually. And in fact, you cannot really do so even if you wanted to. You have to use some sort of data source.
I guess I just don't understand the question you are asking.