I am working on a program that contains multiple DataGridViews on multiple tab controls. My DataGridViews have a lot of initial formatting done to them at runtime. For example, row 0 and 1 are my first set of "headers" which are read only cells with color and font formatting. Rows 2 and 3 are for data entry with color coding based on values entered. Then, this row organization repeats for rows 4, 5, 6, and 7, then, so on.
I do not want to have to repeat all the setup and formatting code for all the other DataGridViews. Is there a way to create an array of DataGridViews so that I can loop the setup and formatting code?
DataGridView[] subFrames = new DataGridView[16];
The above compiles, but how does one use this? I cannot name a DataGridView control on my form subFrame[0]. Do I have to create the control and define placement, etc in code to do this? Or is there another way?
DataGridViews themselves static (and simply numerous), or are they dynamically generated somehow?DataGridViewfrom adding that instance to the array?DataGridViewinstances are objects like any other objects in C#. You can create an array and just set them as the elements of that array for quick access to them.