Hi
i have UltraGrid with 2 bands (parent /child) and i noticed that sometimes when the i expand or collapse then the vertical scrolling possition is changed. this happens when the vertical possition is not at the top
for example
when i expand about 4 parents to show their child band then and then scroll down and then collapse the lower parent to hide its child then the whole grid slides downwords. it complicates what i am trying to acheive - syncing two ultragrids side by side, but i am trying to take care of that,
so i play with ActiveRowScrollRegion.ScrollPosition but the problem is that i am unable to catch the correct value of it inorder to assign it to the second grid . and perform something like
ug2.ActiveRowScrollRegion.ScrollPosition = ug1.ActiveRowScrollRegion.ScrollPosition;
here is the events flow that i understand happening after collapse/expand click
1. _BeforeRowCollapsed/Expanded
2. _AfterRowCollapsed/Expanded
3. _BeforeRowRegionScroll
4. _AfterRowRegionScroll
the problem that the ug.ActiveRowScrollRegion.ScrollPosition is not changing during this flow. only sometime after the 4th event mentioned above. i know this because at the ug_Paint event i am constatly writing the ug.ActiveRowScrollRegion.ScrollPosition and after the whole operation was completed it has different value then the value it had during all 4 events stated above.
so my assumption that there is another event after _AfterRowRegionScroll happening which during that event the ug.ActiveRowScrollRegion.ScrollPosition gets changed and at that point i need to do "my thing".
any thoughts?
Hi,
You are probably right, the ScrollPosition probably isn't updated until the grid paints. There are no other events that fire synchronously, but what you could do is call grid.Update to force the grid to paint before you get the ScrollPosition. That way, it will force the ScrollPosition to be updated synchronously.
was so excited to test this but now that i tried it just now but it doesnt do it :(
i did the grid.Update() at the _AfterRowRegionScroll event but it doesn't change the ScrollPosition . it does force the grid to paint but when i check the ScrollPosition at the _Paint event it doesn't change .
please, any other ideas?
i have decided to drop this silly syncing between two grids and doing everything on one grid because i would have to take care of each sort / filter / scrolling action to keep both grids in sync
it was very stupid of me and way time concuming to do that anyway when there are so many options like Fixed Columns and Scroll Regions.
thank you for your support and please disregard this thread.
many thanks.
Hello sharik,
Thank you for your feedback, I am glad to hear that we were able to solve this. Please do not hesitate to ask if you face another issue, I will be happy to assist you.
thanks boris for the consistant responses and support
as you might have seen from my code that i have tried it the other way arround.
at ugData_AfterRowExpanded event to do
ugExcel.ActiveRowScrollRegion.ScrollPosition = ugData.ActiveRowScrollRegion.ScrollPosition;
i tried now your solution on the ugExcel_AfterRowExpanded event, and presto, it did work !! it kept the vertical scroll region in sync ! that would probably be the only thing that i have not tried yet....
again thanks for the support !
I spent some time looking into your sample and came with one solution - putting the following line at the end of the 'AfterRowExpanded' event:
ugData.ActiveRowScrollRegion.ScrollPosition = ugExcel.ActiveRowScrollRegion.ScrollPosition;
Please do not hesitate to contact me if you need any additional assistance.
i've attached the sample. the problem is at ugData_AfterRowRegionScroll which at that event i wasn't able to sync the grids. if i expand the first and second nodes and scroll down like 3 lines with the vertical scrollbar at the right side of the form and then expand or collapse the 3rd node then the left grid scroll will go up or down just a bit ! but i can't get the right grid to scroll with it
while reviewing my sample you can check the customized behaviour that i've created on the right grid.
expand one of the nodes (or all) and :
1. when mouse is on headers you can click and slide the columns left and right
2. when selecting different value from combo box the grid will slide to the relevent place. with automatic adjustable speed which depends on the distance that it is going to travel.
3. when sliding the columns to a middle of any column it will complete the slide to the begining of a column depending if you have released the mouse button after or before the middle of that column.
3. Excel like replication of cell. on the left grid child rows drag one cell to the left and the value will replicate to that cell under the mouse. and with your help it is now confined to that same row.
If it is sufficient for you, I can take a look of course. I am in full agreement about 6. though :-]
Please do not hesitate to ask if something comes up, admittedly.