Welcome Guest! To enable all features please
Login or Register.
I use LoadFromArray and LoadIntoArray to quickly populate one grid from another. But this does not include the formatting of the cells. To do that I have to iterate through every cell to make the destination cells/grid match, visually, the source grid. Can there be an option to copy formatting in one call?
Another way to think about this is a "copy" grid function - where everything about the grid is copied including data and formatting. Both grids would still need to be initially designed and created as separate controls. Said another way, a LoadFromArrayWithFormatting and LoadIntoArrayWithFormatting method.
I have several complex grids that I have to duplicate and display on a pop-up form while a user is working on another grid in another form. The original grids (5) are on Tab1 of a multi-page control. The user will switch to Tab4 to make changes in other grids. As those changes are made on Tab4, I update several grids on Tab1. All works well. Think of Tab1 as a scoreboard: it's summarizing and calculating information based on the detailed work being done on Tab4.
To prevent the user from having to tab back and forth between Tab4 (detailed work) and Tab1 (summary information), I allow them to 'pop out' Tab1. All that really is is a new form with grids that look identical to the grids on Tab1. However, they are completely separate grids with different names. As the user makes changes on Tab4, the pop-out grids changes and update just like the grids on Tab1. To pull this off, every time a change is made in a grid on Tab1, I reload the corresponding grid on the pop-out form using the LoadIntoArray/LoadFromArray which is very quick and efficient. But to get the dynamic formatting to match - colors, fonts, etc. based on cell values in the original grid - I have to iterate through the original grid, cell by cell, to make the grid on the pop-out form match and this is not very efficient.
Another example of this is that on 3 of the 11 tabs on the multi-page control I have the 'same' grid: a list of clients being edited as a group. I need the user to be able to see all the clients and key information about the clients on these three tabs. To 'trick' the system I create three separate grids, do the LoadIntoArray/LoadFromArray thing, then iterate through the cells to make the three grids stay in sync. I'm really only updating one grid and just making the other two look identical. This is much faster and a less error-prone process than repeating the code to make the same change in all three grids.
Edited by moderator
| Reason: Igor/10Tec ammended subject, added implementation status
An interesting suggestion, the LoadFromArrayWithFormatting and LoadIntoArrayWithFormatting methods. How do you think they should store formatting in the array they operate? Which format settings should be exported/imported? What about combo lists which can exist only within one iGrid?
There are a lot of questions if we try to implement what you suggested.
Igor. I agree - this sounds simpler than it probably is behind the scenes. But I'm thinking that a multi-dimensional array may work. Probably just the key formatting items: font name; font size; bold; italic; fore color; back color; FmtString etc. I realize this opens a can of worms because given an inch everyone would want a mile - they'd want every property. What about row height? Row visible? Column widths? I'm more thinking of things that dynamically change from code, not the original design of the grid itself. I'm sure a tree grid is even more complex.
Another thought is to have a parent/child grid relationship. A "child grid name" would be a property of a parent grid. Any change to the parent would simply be duplicated in the child grid. Autowidth column 2 in the parent and column 2 in the child also gets updated. Change the order of columns in the parent and the columns change in the child. This too could get complex. What if the grids don't match exactly? Can a change in the parent without a corresponding child element just be ignored. Using my column example, what if the parent had a column that the child didn't have? Can any change to the parent column be ignored in the child grid? In this example it would have to be by column key since column numbers wouldn't be aligned.
Maybe when you define the parent grid - columns, background color, header styles, etc. - if it has a ChildGridName the child grid inherits those same properties and you never have to define that info for the child grid. Prevents the issue of the child and parent not matching 100%. It simply forces the grids to be identical. The developer would simply place a unique grid on a form and maybe it has a property to point back to the parent as well as the parent having a pointer to the child. But that's it; no need to define any fields or features of the child grid.
Lastly, where it get really complex (I think) is functions generated from within the grid. Let's say a parent grid has a checkbox cell that, once checked, executes some code. Can I check the corresponding child checkbox and execute the same code without duplicating the code behind the checkbox? Just so you know, for my pop-out form with the duplicated grids, I severely limited functionality for this reason. I didn't want to duplicate code or do a lot of excessive coding so that each checkbox event pointed to the same block of code. I would have done that if necessary, but for my client, they didn't really need that depth of functionality on the "scoreboard" view. I dodged a bullet on the scorecard form.
On the three client grids I mentioned, there is some functionality that I did duplicate across all three grids, but that was a trade-off vs. combining all the grid functions to one block of code. Could of gone either way on this one. So on these three grids I have to always update the other two grids, no matter which grid they choose to use, so there's a bit of coding to make this all happen.
Thanks for thinking about this.
- You cannot post new topics in this forum.
- You cannot reply to topics in this forum.
- You cannot delete your posts in this forum.
- You cannot edit your posts in this forum.
- You cannot create polls in this forum.
- You cannot vote in polls in this forum.