Hello,
I am learning VB2005 by rewriting a large VB6 program. My VB6 program used loads of MSFlexGrids in a single Control Array.
Control Arrays are out with VB2005 so I was looking at a way of using DataGridView controls in the form of a collection.
The MSDN documentation points in the direction of DataGridViewControlCollection but I cannot decifer how to add DataGridViews to form a collection and then how to access each one in a similar fashion to my VB6 Control Array.
My VB6 program loads the MSFlexGrid's in this simplified fashion:
For I=0 to MaxFlexGrid
With MSFlexGrid1(I)
Code to load cells
Next I
Is the DataGridViewControlCollection the best way to duplicate my VB6 functionality If so would you be able to share some code examples for the collection creation Also any examples on how to load/access the DataGridView's in the collection.
Thanks

How to use DataGridViewControlCollection in place of Control Array of MSFlexGrids
David Langford
well, the idea for binding would be to create a class that represents a row, load them into a BindingList generic and bind that to your grid.
you can still create an array of controls
dim mygrids() as DataGridView
but this will only be used to reference other grids.
the only real advantage I know of that Control arrays gave was the ability to share event handlers. This was necessary because VBSUX does not support delegation (can you tell I despise vb6
) .
shoot me an email, I've got some ideas that might work-
Custom list that reads -> decrypted / writes-> encrypted
Enumeration that maps views to grids.
It might look dark right now, but I think you will find that the amount of code you need to accomplish your task will decrease dramatically.
Its all matter of a paradigm shift!
Parag Gaikwad
by DataGridViewControlCollection, do you mean the DataGridView.Controls Collection
I dont think that is what you are looking for.
I assume by "Code to load" MsFlexGrid "Cells" you were iterating through a data structure and loading the data physically into the grid (that must have been excrutiatingly slow) instead of databinding.
Controls are not Data Structures but the presentation of your Data Structures.
simply bind your DataGridView.DataSource to an object that implements one of the appropriate interfaces and the grid is "loaded". . . well not really. . . the data in the IList is presented in the grid.
take a look at "DataGridView.DataSource" in the help file
the VBSUX way of doing things was wrong. Beyond simple syntax, there is very little in common with .Net (and that's a good thing)
Steve Nelson
Thanks for the response.
My VB6 physical data is in a single encrypted file so yes I did iterate through a structure and load data into the grid. Actually the program response was very good.
I'm finding the VB6 to .Net/VB2005 transition to be a huge re-education, almost everything I've done must change.
I like the power of the DataGridView control but because of the security issues and the single data file I don't see a way to bind the data. I'm still out to lunch on the subject and need help.
Considering my data's structure and format is there a way to bind it to a DataGridView If not it appears that I will still need to iterate through things and the DataGridView gets used like an MSFlexGrid.
How does one create a collection of FlexGridView's that facilitates a VB2005 use of VB6 Control-Array's
Thanks