Hello Guys,
Hope you are doing great. Here I have an issue with infragistics grid. On my grid I have several row so I need to scroll down to go to the bottom of the grid. So if I select a row in thr grid and if I update it and if I refresh the grid, its taking me to the top of the page which is very annoying.
So the requirement is it should take me to the row where I was working on.
Can anybody help me with this.
Our APP is WINFORMS AND INFRAGISTICS.
This is where I mentioned in my second post that likely the index isn't the best way to do this. You'll have to store some sort of information that can be used to locate the row later, either by looping through the rows in the data source or through the rows in the grid, then activating that row. There really isn't going to be a better way of doing this since there will be new instances of UltraGridRow objects, so you can't store a direct reference to that row before re-binding.
-Matt
Hey Matt,
That logic works for me. But here is another scenario. If I delete a row and rebind the grid then it throws an error saying that the rowindex is out of bound.
I think we have verify before making the row activate whether its actually exists or not.
Can you please help me with this.
As an additional point, my code will only work if the order of the rows are the same, so it is fairly limited. If there's any chance that the order will be different, or have a different number of items, your best bet is to store some information that can be used to identify the row after rebinding, then locate that row and activate it after rebinding the grid. The activation process should handle scrolling the row into view.
Yeah Matt, Im sorry to be not clear. Yeah Im trying to rebind the grid completely as one selected row is updated and I wanted to keep foucs on that row when the user updates the row and refreshes the grid.
Anyways let me try with that and will let you know.
What do you mean by "refresh the grid"? Are you completely rebinding the grid, or doing something that would otherwise cause a Reset notification to be sent to the grid? If this is the case, then the grid regenerates its rows, causing you to lose the scroll position. What you could do is keep track of which row is active, by index, and simply activate the row again, i.e.
int rowIndex = -1;if(grid.ActiveRow != null) rowIndex = grid.ActiveRow.Index;// Refresh gridif(rowIndex > -1) grid.Rows[rowIndex].Activate();