Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
Upgraded from v8.2 to v19.1: UltraGrid InitializeRow fires no longer synchronously when setting DataSource
posted

We have recently updated an old Windows Forms project from Infragistics NetAdvantage 2008 (v8.2) to the latest Ultimate UI 2019 (v19.1). Despite the versions being 10 years apart the upgrade was smooth.

We do run into an issue, though: The firing behavior of the UltraGrid InitializeRow event when setting DataSource has changed.

In the old version, InitializeRow was fired synchronously for every row while setting DataSource. In the new version it is not fired directly by setting DataSource, but asynchronously while repainting the control.

This change in behavior causes issues in our application. Sometimes global variables are set/calculated in InitializeRow which are consumed directly after setting DataSource. Because InitializeRow now fires asynchronously, this code no longer works correctly.

Probably this is just plain bad coding style but we have _a lot_ of InitializeRow events in the application and analyzing & modifying all might take a lot of time. Before we dive into this adventure, my question is...

Is there perhaps a setting or a code trick in the new UltraGrid to force the old behavior where InitializeRow fires synchronously while setting DataSource? Thanks!


Example code (Windows Forms, C#, .NET 4.x):

private static DataTable GetDataTable()
{
    var dataTable = new DataTable();
    dataTable.Columns.Add("Number", typeof(int));
    dataTable.Columns.Add("Text", typeof(string));
    for (var i = 0; i < 5; i++)
    {
        dataTable.Rows.Add(i, $"Row {i}");
    }
    return dataTable;
}

private void Button_Click(object sender, EventArgs e)
{
    textBox.Clear();
    textBox.AppendText("Begin setting UltraGrid.DataSource\r\n");
    ultraGrid.DataSource = GetDataTable();
    textBox.AppendText("End setting UltraGrid.DataSource\r\n");
}

private void UltraGrid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
    textBox.AppendText("InitializeRow\r\n");
}

Left v8.2, right 19.1:

Full sample source code available on request (includes v8.2 and v19.1 project for Visual Studio 2017)