Hi,
I am trying to figure out a way to make 3 separate ultra grids act as one.
The three grids are stacked vertically and they all have the same columns, but they all draw data from different data sources. What I'm currently trying to do is make all the column widths update to the same size in all three grids whenever the column widths are adjusted by dragging the columns at run time.
If I can get some sample code on how to do this, that would be great.
Hi Tatiana,Thank you for posting in our forums.What you could do in order to implement this is to handle the BeforeColPosChanged event, which is raised when a user moves, resizes or hides a column. In that event you can transfer the change to all the grids. This way you can synchronize the sizes and positions of the columns.I have attached a small sample which demonstrates how to implement this. Note that it relies on all the grids having the same band keys and same column captions.Let me know if you have any additional questions.
Hi Dimitar,
Thank you for your post, it was very helpful and is much appreciated. However, my issue seems to be that I have my grids AutoFitStyle property set to ResizeAllColumns, and this is not allowing the grid columns to be of exact column widths after adjusting the size. The code works if this property is set to None or ExtendLastColumn, but I would like my columns to be able to fit the entire screen, without using ExtendLastColumn. Do you know if there is a way to work around this?
Thank you,
Tatiana
Thanks Dimitar, that's exactly what I was looking for!
Hi Tatiana,Thank you for the reply.Ok, I was able to align the columns perfectly doing three modifications to my sample. First I also switched to the AfterColPosChanged event. Then I changed the method that modifies the columns to iterate all the columns in the band and set their size based on the columns in the modified band. And finally I now call the method asynchronously. This allows the grid to finish up its layout logic and only then to synchronize the other grid.I have attached my modified sample. Note that I also included a simple DrawFilter, which visualize if the grids columns are aligned.Let me know if you have any additional questions.
If you look closely, the columns are slightly off and not exactly aligned when using ResizeAllColumns. I feel like the widths get slightly adjusted after the BeforeColumnPosChanged method gets called. I have also tried using the AfterColumnPosChanged method but I still get the same results.
Hi Tatiana,Thank you for posting in our forums.I modified my sample to use AutoFitStyle to ResizeAllColumns and it still works fine. I am attaching my modified sample. As you can see, changing the width of any of the columns is reflected in all the grids. Let me know if this is what you are looking for.I am looking forward to hearing from you.