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. If you have any other questions about synchronizing two 'WinGrid' instances, please do not hesitate to ask.
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
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.
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.