Declined
Last Updated: 24 Aug 2015 13:05 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 24 Nov 2014 17:08
Category: GridView
Type: Bug Report
1
FIX. RadGridView - Slow scrolling when Image from an ImageList is applied to the cell in the CellFormatting event
DECLINED: This happens because you are setting a non-image value to a GridViewImageColumn. The GridViewImageColumn is designed to work with image data directly and if any non-image data is used with this column, this will result in a large number of internal exceptions which are thrown while the column tries to read the image. The throw operation is an expensive one and this causes the slowdown. Also, note that the slowdown is much heavier when running the application with the debugger attached, because when this is the case, each internally thrown exception is written to the console, and writing to the console is an even more expensive operation. 

If the image is to be applied on the CellFormatting event and the value of the cells in a column are not going to be images, then GridViewTextBoxColumn should be used instead.

To reproduce: add a RadGridView and an  ImageList with two images. Use the following code snippet:

public Form1()
{
    InitializeComponent();

    DataTable dt = new DataTable();
    for (int i = 0; i < 10; i++)
    {
        dt.Columns.Add("Pic" + i);
    }
    
    for (int i = 0; i < 100; i++)
    {
        DataRow newRow = dt.NewRow();
        foreach (DataColumn col in dt.Columns)
        {
            newRow[col.ColumnName] = i;
        }
        dt.Rows.Add(newRow);
    }
    radGridView1.AutoGenerateColumns = false;
    
    for (int i = 0; i < 10; i++)
    {
        GridViewImageColumn imgCol = new GridViewImageColumn("col" + i);
        imgCol.Width = 100;
        imgCol.FieldName = "Pic" + i;
        this.radGridView1.Columns.Add(imgCol);
    }

    this.radGridView1.DataSource = dt;

    this.radGridView1.CellFormatting += radGridView1_CellFormatting;
}

private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.Row is GridViewDataRowInfo)
    {
        e.CellElement.Image = this.imageList1.Images[e.RowIndex % 2];
    }
}
1 comment
ADMIN
Ivan Todorov
Posted on: 17 Dec 2014 14:40
DECLINED: This happens because you are setting a non-image value to a GridViewImageColumn. The GridViewImageColumn is designed to work with image data directly and if any non-image data is used with this column, this will result in a large number of internal exceptions which are thrown while the column tries to read the image. The throw operation is an expensive one and this causes the slowdown. Also, note that the slowdown is much heavier when running the application with the debugger attached, because when this is the case, each internally thrown exception is written to the console, and writing to the console is an even more expensive operation. 

If the image is to be applied on the CellFormatting event and the value of the cells in a column are not going to be images, then GridViewTextBoxColumn should be used instead.