开发者

ultragrid scroll

开发者 https://www.devze.com 2023-02-13 14:57 出处:网络
When i insert a new row into ultra win grid the scroll positio开发者_StackOverflow社区n is changing how to keep my scroll position C# application framework 2.0not entirely sure what you mean ? can u e

When i insert a new row into ultra win grid the scroll positio开发者_StackOverflow社区n is changing how to keep my scroll position C# application framework 2.0


not entirely sure what you mean ? can u elaborate/provide more detail?

  • you select any row first (either programatically or by clicking it). and any rows you add shouldnt chnage the positon

  • there was also way you can bring particular row into view (i think it was called ScrollIntoView() or BringIntoView(), look at Infragistics API).


From what I can understand is that you want to keep your current row selected after refresh or inserting a new row. You will have to keep your current active row index in memory and then manually scroll back to it. Here in an example of code

    private void btnTestActiveRow_Click(object sender, EventArgs e)
    {
        var activeIndex = ultraGrid1.ActiveRow.Index; // get the activerow index

        scrollPos = ultraGrid1.ActiveRowScrollRegion.ScrollPosition; 


        ultraGrid1.DataSource = null;
        ultraGrid1.DataSource = dal.GetData(); //refreshing the grid



        ultraGrid1.ActiveRowScrollRegion.ScrollPosition = scrollPos;
        ultraGrid1.Rows[activeIndex].Activate(); 
        ultraGrid1.Rows[activeIndex].Selected = true;

    }


if(grd.ActiveRow != null) 
{
   grd.Refresh();
   grd.ActiveRowScrollRegion.ScrollRowIntoView(grd.ActiveRow);
   grd.ActiveColScrollRegion.ScrollRowIntoView(grd.ActiveRow, grd.ActiveRowScrollRegion);
}

Scrolls to the current ActiveRow.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号