Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Setting ImageIndex too slow

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Setting ImageIndex too slow
Link Posted: 28-Jun-2007 05:54
I have a FlyGrid, which takes too long to update the ImageIndex. For example this tree has 100 nodes and it tool 25 seconds to update the images. Any ideas how to optimize performance. I have other trees which have 1000 node.


            foreach (TreeViewNode node in this.treeTest.Rows.SelectedNodes)
            {
                node.ImageIndex = 1;
                node.SelectedImageIndex = 1;
            }
Link Posted: 05-Jul-2007 16:39
Changes of ImageIndex/SelectedImageIndex are slow because FlyGrid needs to repaint images on the screen. Use following code to increase speed of updates:
[c#]
this.treeTest.BeginInit();
try
{
  foreach (TreeViewNode node in this.treeTest.Rows.SelectedNodes)
  {
    node.ImageIndex = 1;
    node.SelectedImageIndex = 1;
  }
}
finally
{
  this.treeTest.EndInit();
}
Link Posted: 05-Jul-2007 21:45
The proper answer is :


if (!Grid.IsDisposed) Grid.EndInit();


otherwise you will have intermittent exception (which covered by try/catch in the previous answer though). But I believe that learning the root of the problem is better strategy than flooding your code with try/catch.
Link Posted: 06-Jul-2007 03:56
BeginInit / EndInit does not make a difference. Is there a particular image type it will work better with e.g. .bmp .png .jpg?