Completed
Last Updated: 22 Mar 2022 13:50 by ADMIN
Release R2 2022 (LIB 2022.1.322)
Dinko
Created on: 04 Mar 2022 12:28
Category: GridView
Type: Bug Report
0
RadGridView: InvalidOperationException is thrown when a row is expanded and the AutoSize property is true

When the RadGridView AutoSize property is set to true and a row is expanded, an exception is thrown:

System.InvalidOperationException: 'MeasureOverride returned positive infinity: Telerik.WinControls.UI.GridDetailViewRowElement'

 

A possible workaround is to replace the GridDetailViewRowElement with your own class. Then overriding the MeasureOverride method we can pass valid size to the element.

private void RadGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
{
    if (e.RowInfo is GridViewDetailsRowInfo)
    {
        e.RowElement = new MyGridDetailViewRowElement();
    }
}

public class MyGridDetailViewRowElement : GridDetailViewRowElement
{
    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        var baseSize =  base.MeasureOverride(availableSize);
        if(baseSize.Width == float.PositiveInfinity)
        {
            baseSize.Width = 800;
        }
        return baseSize;
    }
}

0 comments