Hi All,
I have an UltraGrid bound to a BindingSource which is being updated via a backgroundworker. When my background process is completed, the following method is called:
try
{
UltraGridRow r = dgOrders.DisplayLayout.ActiveRow;
int firstVisible = dgOrders.ActiveRowScrollRegion.FirstRow.Index;
dgOrders.BeginUpdate();
dgOrders.SuspendLayout();
dgOrders.DataBind();
if (r != null)
dgOrders.ActiveRow = r;
dgOrders.ActiveRowScrollRegion.FirstRow = dgOrders.Rows[firstVisible];
}
dgOrders.ResumeLayout();
dgOrders.EndUpdate();
catch (Exception ex){}
What I'm aiming to do is to keep the current active row activated and to keep the scroll bars from shifting when the grid calls DataBind(). This works perfectly fine when I there are no GroupByRows, when there are GroupByRows the FirstRow property of the grids ActiveScrollRegion ALWAYS returns a GroupByRow (even if a normal UltragridRow is at the top of the visible portion of the grids display area). This makes is very difficult to determine where the first row of the scroll region should be set after the update.
Has anyone run into something similar when using GroupByRows?
Thanks,
Sean
Hi Sean,
I'm glad you got it working.
But FYI, binding the grid or any control to a data source that is being modified on another thread is an extremely dangerous thing to do.
Neither the WinGrid not the BindingManager are thread-safe. There are several detailed discussions of this on these forums, such as this one:
Work with a dataset bound to a grid on a separate thread - Infragistics Community