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?
Mike, i haven't tried that, maybe later but thanks .
Boris, yes i gave that up because once i understood that there are fixed headers there was not much point to have two sepereate grids , one static(fixed) and one scrollable.
Syncing between two grids has much more aspects then i tought of initially.
Syncing the following :
1. Scrolling
2. .ActiveRow/SelectedRow
3. Expand Collapse
4. Sorting
5. Filtering
6. and maybe more
items 1 and 2 took me a long time to fikle with, and i got stuck at item 3 which led me to start this thread. Syncing Expand and Collapse using the events are easy but there was something happening to the vertical scroll when the scroll was in the middle for instance and i would do expanding or collapsing , the grid vertical scroll would change a bit, and that was something i couldn't overcome to catch that correct vertical scroll possition value.
all this before even reaching to items 4 and 5 and then understanding there are few things i've missed.
Now that i've made it as one grid and fixed the headers (which you helped me in a different thread about the filtering icon) everything is working good and i'm satisfied with the resaults.
if you really and truely want to "get into" the problem i had during item 3 then i can upload the previuse project and explain where i had the problem.
Hello sharik,
This is a designer's decision about the Fixed headers. Is there something that is bothering you? Did the property help you in the end? Did you entirely gave up the idea of syncing the two grids?
Please let me know if I can help with something else.
Hm, that's unfortunate. The only other potential solution I can think of would be to move the code out of the event handler and into a separate method and then cal that method using a BeginInvoke. That should create enough of a delay so that by the time the method is called, the grid has updated the scroll position.
Thanks Mike, out of pure curiocity i had to check it, and i didn't delete this project so i did check it.
and it didn't help, in the ugLeft_AfterRowRegionScroll i did this :
ugLeft.DisplayLayout.UIElement.DirtyChildElements();
ugLeft.DisplayLayout.UIElement.VerifyChildElements();
ugLeft.Update();
ugRight.ActiveRowScrollRegion.ScrollPosition = ugLeft.ActiveRowScrollRegion.ScrollPosition;
ugRight.Refresh();
when this event starts then both grids .ActiveRowScrollRegion.ScrollPosition are equal and expected that after the ug1.Update() would occure then they would become different . but no, they are still same values . only after i keep pressing F10 and as it goes to ugLeft_Paint event then the ugLeft.ActiveRowScrollRegion.ScrollPosition changes to what i expected it to. my solution to this was to create a flag and when ugLeft_AfterRowRegionScroll to set flag=TRUE and at the ugLeft_Paint to say "if (flag==true) ... then do
and then set the flag=False;
this is the ugliest solution ever but i think it would have worked. but as i said , it was silly of me to do "syncing" of 2 grids when there is such a wonderful feature as Fixed Headers.
by the way, why it is called Fixed Headers (column.Headers.Fixed) and not Fixed Columns (column.Fixed) ? :-)
Boris, thanks for your reply as well
Thank you for your feedback. If you have any other questions about synchronizing two 'WinGrid' instances, please do not hesitate to ask.