user1169502
user1169502

Reputation: 398

Infragistics UltraGrid - event after grid initialized

I am using an Infragistics UltraGrid in V15.1 and have an issue with the time it is taking to initialize the grid as I am using the 'InitializeRow' row event to colour and format each row in the grid. I want to display a 'busy' image while this is taking place as it can be many seconds to process. Displaying the image is no problem but I can't see any event which is fired once all of the rows have been initialized and the grid is being displayed. If I just add it around the bit where I populate the grid this is almost instant but the InitializeRow takes place after that...

Upvotes: 2

Views: 4281

Answers (1)

Mike
Mike

Reputation: 206

There is no event that fires when the grid is done initializing all of the rows because the grid is never really finished Initializing the rows. DataBinding is an ongoing process, not a one-time thing. Rows are Re-Initialized when a value in that row changes, or if a new row is added to the grid or the data source.

Steve is probably on a the right track. You should look into ways to speed up the process. InitializeRow shouldn't take that long and if it's taking a long time, chances are the code can be improved to make it more efficient. Check out the WinGrid Performance Guide for some tips or post the code here and I'd be happy to take a look.

If you absolutely most show a wait indicator, then a lot depends upon the order in which you are doing things to the grid. Are you binding the grid and then adding the rows to your data source? Or are all the rows added first? Is anything in your code forcing the grid to paint?

In a very small sample, I had some success using the Paint event. But I imagine this might not work in all cases, especially if your code does something that forces the grid to paint prematurely.

    private void Form1_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 10000; i++)
        {
            this.ultraDataSource1.Rows.Add(new object[] { i });
        }

        this.ultraGrid1.Paint += UltraGrid1_Paint;
    }

    private void UltraGrid1_Paint(object sender, PaintEventArgs e)
    {
        this.ultraGrid1.Paint -= UltraGrid1_Paint;
        Debug.WriteLine("PAINT");
    }

    private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
    {            
        Debug.WriteLine(e.Row.Index, "InitializeRow");
    }

Upvotes: 2

Related Questions