Hi I have a ultraGrid and using datasource to bound as
grid.SetDataBinding(List , null, true);
If any addition or updating the list I am using like
_list.Add(newItem) ;
_view.List = _list;
My problem is if I scroll the grid down and add or update the list scroll is going to top which I dont want.
I have UltraTree and behaving the same .
I want not to move the scroll position until user move it.
Please advise.
I'm not sure I understand what you are describing. It looks like the new row you are added would be added to the bottom, since you are using Add and not Insert. So I don't see anything here that should cause the list to scroll.
But I'm not sure what _view is here or why you are re-assigning it every time you add an item to your list.
Hi
I am describing again about my issue here below.
1)I am binding List to grid as below.
I am using sorting for rows and groups.
2) I am doing insertion , addition, delete and update to the List and doing the same binding again
Scroll bar is going to top always because I am sorting the rows always.
I am doing the same to TreeView. TreeView 's scroll bar also going to Top .
Is there any other way I can avoid to scroll to top when data refresh.
Thanks
Actually I wrote a code to maintain the scroll position and active row after binding reset, but I think you're doing something wrong here. You don't need to bind your list again on any change. That's what binding is all about. You should use a BindingSource as your grid data source and set the list as the data source of the BindingSource, or use a BindingList instead. These types know to handle grid update when there is a change without losing the scroll position, unless their data source (your list) has been reset (which is why I wrote my code to maintain the scroll).
Hi I am binding Business Object list to datasorce. My business object is not implementing IBindigList.So binding source not working.
Please could you give me the solution to the existing written code . Since we dont have time to go back we can't change our code now.
Old thread, but I just had this problem when using e.Cell.Row.Update() (or any other UpdateData() type function on the Grid) from CellChange.
To fix it, I've stored m_FirstRow = xx.FirstRow, then set the FirstRow in AfterRowScrollRegion, then immediately setting it to null (or you can't manually scroll).
Hope this helped someone else!
Thanks for the prompt and quick response. It is working now.
Well, you need a way to compare entities. In my project each entity has an ID which is the primary key.
1. In AfterRowActivate event, save the row ID somewhere.
2. In AfterRowRegionScroll, save the ID of e.RowScrollRegion.FirstRow
3. After you set the data again, search for the row with the ID in (1) and call row.Activate().
4. and, search for the row with the ID in (2) and set: grid.DisplayLayout.RowScrollRegions[0].FirstRow = row.