Hi everyone
i have 2 wingrids on a form. Those two girds can be compared row by row.
The functionality i wanted is, when i scroll one grid, the other grid should also scroll to the same position.
I found a example to do this in datagridview, but the properties used there are not present in wingrid.
The link to the example is below:
https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1373096&SiteID=1
Help me out by solving the above mentioned problem.
Thanks in advance
Navi
Navi,
You could use the AfterRowRegionScroll event to control the scrolling of the two grids, such as:
private bool isInScroll;private void ultraGrid1_AfterRowRegionScroll(object sender, Infragistics.Win.UltraWinGrid.RowScrollRegionEventArgs e){ if (this.isInScroll) return; try { this.isInScroll = true; this.ultraGrid2.ActiveRowScrollRegion.ScrollPosition = e.RowScrollRegion.ScrollPosition; } finally { this.isInScroll = false; }}private void ultraGrid2_AfterRowRegionScroll(object sender, Infragistics.Win.UltraWinGrid.RowScrollRegionEventArgs e){ if (this.isInScroll) return; try { this.isInScroll = true; this.ultraGrid1.ActiveRowScrollRegion.ScrollPosition = e.RowScrollRegion.ScrollPosition; } finally { this.isInScroll = false; }}
Note that a flag is used to make sure that we don't enter a recursive situation where we're constantly causing the grids to scroll. This code will work without the flag, but will be much slower due to the additional overhead.
-Matt
Hi Matt
Thanks for the reply. There is a slight change in the question i have asked you.
One wingrid is in the form and the another wingrid is on a control which is assigned to panel in the form programmaticall.
Can you tell me how to get the instance of that wingrid which is on control to the form to use the above mentioned solution?
Or is there any other way to solve this problem
Thanks in Advance
I'm not sure what you're asking. You would just need to hook up the two grids to the two event handlers that I have provided you; if you're creating the form programmatically then you should be able to add an event handler when you create it. If the two grids are in different, inaccessible areas, you will somehow need to expose something to allow you to hook up the two event handlers, or even a method to set the grid's scroll position.
May be i didnot explain the question properly.
I created a form in design mode and then added a wingrid to it and also added a empty panel to it.
Now i created a seperate control form and added a wingrid to it in design mode.
Now programmatically i have added this control form to the empty panel.
So finally when we run the program we will have two wingrids side by side.
Now i have to make these two wingrids scrolling symultainously.
May be i have to use delegate event to do this.
Can you give some example to do this
From what you just described it still sounds like the same issue that I was referring to. You have 2 grids, and they are both on the same form, right? Though one is within a panel and the other is not. However, in code you are moving this grid to be inside the panel so you *have* a reference to the grid. You then add an event handler to this grid the same way that you would add any other event handler, i.e. "this.ultraGrid1.AfterRowRegionScroll += new Infragistics.Win.UltraWinGrid.RowScrollRegionEventHandler(this.ultraGrid1_AfterRowRegionScroll);". It doesn't matter that it's in another panel as long as it is on the same form as the other grid. Whether you use the exact same event handlers and structure that I do is up to you, if you can't access the underlying grid you need to expose a method that will set the ScrollPosition for you.