Can't add a RadSvgImage to a GridViewImageColumn

1 Answer 35 Views
GridView
Marcio
Top achievements
Rank 1
Marcio asked on 31 Oct 2021, 11:14 PM | edited on 31 Oct 2021, 11:14 PM

Hello, I got this error when I've tried to show a RadSvgImage  in a GridViewImageColumn

 

message: Converter can't convert

stack trace:

  at Telerik.WinControls.UI.RadDataConverter.ThrowFormatException(Exception ex, String message)
   at Telerik.WinControls.UI.RadDataConverter.ChangeType(Object value, Type targetType, IFormatProvider formatInfo)
   at Telerik.WinControls.UI.RadDataConverter.ParseCore(Object value, Type targetType, Type sourceType, TypeConverter dataTypeConverter, IDataConversionInfoProvider dataColumn, Boolean checkFormattedNullValue, CultureInfo cultureInfo)
   at Telerik.WinControls.UI.RadDataConverter.Parse(IDataConversionInfoProvider converstionInfoProvider, Object value, CultureInfo cultureInfo)
   at Telerik.WinControls.UI.GridViewRowCollection.Add(Object[] values)

 

Code


Dim colIdiomaOriginalSvg As New GridViewImageColumn("IdiomaOriginalFoto")


     If gradeParesIdiomasRecursos.Columns.Count = 0 Then
            gradeParesIdiomasRecursos.MasterTemplate.Columns.Add(colIdiomaOriginalSvg)            
     End If

Dim fotoDtpSvg As RadSvgImage = RadSvgImage.FromXml(xmlSvgImage)
gradeParesIdiomasRecursos.Rows.Add(fotoDtpSvg)
Thanks in advange

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Nov 2021, 06:15 AM

Hello, Marcio,

GridViewImageColumn displays read-only images for database columns of Image data type (OLE container or BLOB). 

I have prepared a sample code snippet demonstrating how to display a SVG image inside a CellElement by specifying its SvgImage property: 

    Sub New()

        InitializeComponent()
        RadControl.EnableSvgImages = True
        Dim colIdiomaOriginalSvg As New GridViewImageColumn("IdiomaOriginalFoto")
        colIdiomaOriginalSvg.DataType = GetType(RadSvgImage) 

        If Me.RadGridView1.Columns.Count = 0 Then
            Me.RadGridView1.MasterTemplate.Columns.Add(colIdiomaOriginalSvg)
        End If

        AddHandler Me.RadGridView1.CellFormatting, AddressOf RadGridView1_CellFormatting

        Dim fotoDtpSvg As RadSvgImage = RadSvgImage.FromFile("..\..\computer.svg")
        Me.RadGridView1.Rows.Add(fotoDtpSvg)
        fotoDtpSvg = RadSvgImage.FromFile("..\..\atom.svg")
        Me.RadGridView1.Rows.Add(fotoDtpSvg)

        Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
        Me.RadGridView1.TableElement.RowHeight = 200
        Me.RadGridView1.AllowAddNewRow = False

    End Sub

    Private Sub RadGridView1_CellFormatting(sender As Object, e As CellFormattingEventArgs)
        If e.Column.Name = "IdiomaOriginalFoto" Then
            e.CellElement.SvgImage = e.CellElement.Value
        End If

    End Sub

More information about the vector images is available in the following help article:

https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/vector-images-support 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Marcio
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or