Unplanned
Last Updated: 31 Jan 2024 11:50 by ADMIN
Martin
Created on: 31 Jan 2024 11:34
Category: GridView
Type: Bug Report
0
RadGridView: NullReferenceException in GridCommandCellElement.Detach() when using BestFitColumns
I had the following code:
RadGridview 1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.HeaderCells)


1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 31 Jan 2024 11:50

Hello, Martin,

Thank you for reporting this. To workaround this behavior you can create a custom GridCommandCellElement:

Private Sub RadGridView1_CreateCell(sender As Object, e As GridViewCreateCellEventArgs)
    If e.CellType Is GetType(GridCommandCellElement) Then
        e.CellElement = New MyGridCommandCellElement(e.Column, e.Row)
    End If
End Sub

Public Class MyGridCommandCellElement
    Inherits GridCommandCellElement
    Public Sub New(column As GridViewColumn, row As GridRowElement)
        MyBase.New(column, row)
    End Sub
    Public Overrides Sub Detach()
        If Me.CommandButton IsNot Nothing Then
            Me.CommandButton.Image = Nothing
        End If
    End Sub
End Class

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.