Completed
Last Updated: 15 Aug 2017 11:03 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 27 Jun 2017 09:28
Category: GridView
Type: Bug Report
1
FIX. RadGridView - NullReferenceException when copying an empty cell in GridViewSelectionMode.CellSelect
To reproduce: run the attached sample project:

1. Clear the value in one of the cells.
2. Select the empty cell and press Ctrl+C to copy the empty cell. You will encounter the error coming from the GetFormattedCellValue method.

Workaround: handle the RadGridView.Copying event

private void RadGridView1_Copying(object sender, GridViewClipboardEventArgs e)
{
    if (this.radGridView1.SelectionMode == GridViewSelectionMode.FullRowSelect)
    {
        foreach (var row in this.radGridView1.SelectedRows)
        {
            foreach (var cell in row.Cells)
            {
                GridViewCellInfo cellInfo = cell as GridViewCellInfo;
                if (cellInfo != null && cellInfo.Value == null)
                {
                    cellInfo.Value = "";
                }
            }
        }
    }
    else
    {
        foreach (var cell in this.radGridView1.SelectedCells)
        {
            if (cell.Value == null)
            {
                cell.Value = "";
            }
        }
    }
}
0 comments