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.
精彩评论