3 Answers, 1 is accepted
0
Hello Jacob,
You will need to create a custom editor element and override the SaveValueFromDialog method so that you can extract the values from the multiple file names and use them as a value of the cell. Please check my code snippet below:
I hope this helps. Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
You will need to create a custom editor element and override the SaveValueFromDialog method so that you can extract the values from the multiple file names and use them as a value of the cell. Please check my code snippet below:
Partial Public Class RadForm1 Inherits Telerik.WinControls.UI.RadForm Public Sub New() InitializeComponent() AddHandler radGridView1.EditorRequired, AddressOf RadGridView1_EditorRequired Dim column As New GridViewBrowseColumn("Browse column") Me.radGridView1.Columns.Add(column) Me.radGridView1.Rows.Add("C:\Music\Sting\If You Love Somebody Set Them Free.wav") Me.radGridView1.Rows.Add("C:\Music\Sting\Russians.wav") Me.radGridView1.Rows.Add("C:\Music\Sting\Fortress Around Your Heart.wav") Me.radGridView1.Rows.Add("C:\Music\Sting\Love Is the Seventh Wave.wav") Me.radGridView1.Rows.Add("C:\Music\Sheryl Crow\Run, Baby, Run.wav") Me.radGridView1.Rows.Add("C:\Music\Sheryl Crow\Leaving Las Vegas.wav") Me.radGridView1.Rows.Add("test") AddHandler radGridView1.CellEditorInitialized, AddressOf RadGridView1_CellEditorInitialized End Sub Private Sub RadGridView1_EditorRequired(ByVal sender As Object, ByVal e As EditorRequiredEventArgs) If e.EditorType Is GetType(GridBrowseEditor) Then e.EditorType = GetType(MyGridBrowseEditor) End If End Sub Private Sub RadGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs) Dim editor = TryCast(e.ActiveEditor, GridBrowseEditor) If editor IsNot Nothing Then Dim element = TryCast(editor.EditorElement, RadBrowseEditorElement) Dim dlg = TryCast(element.Dialog, OpenFileDialog) dlg.Multiselect = True End If End SubEnd ClassPublic Class MyGridBrowseEditor Inherits GridBrowseEditor Protected Overrides Function CreateEditorElement() As RadElement Return New MyRadBrowseEditorElement() End FunctionEnd ClassPublic Class MyRadBrowseEditorElement Inherits RadBrowseEditorElement Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(RadBrowseEditorElement) End Get End Property Protected Overrides Sub SaveValueFromDialog() If Me.DialogType <> BrowseEditorDialogType.OpenFileDialog Then MyBase.SaveValueFromDialog() Return End If Dim dialog As OpenFileDialog = TryCast(Dialog, OpenFileDialog) If dialog IsNot Nothing Then Dim value As String = String.Empty If dialog.Multiselect Then Dim sb As New StringBuilder() For Each path As String In dialog.FileNames sb.Append(System.IO.Path.GetFileName(path)) sb.Append(";") Next path value = sb.ToString() Else value = dialog.FileName End If Me.Value = value End If End SubEnd ClassI hope this helps. Should you have any other questions do not hesitate to ask.
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jacob
Top achievements
Rank 1
answered on 09 Apr 2019, 03:25 PM
I am getting a null exception thrown. I believe it is due to the line below. My visual studio is replacing Dialog with dialog
which is throwing a warning.
Dim dialog As OpenFileDialog = TryCast(Dialog, OpenFileDialog)
0
Hello Jacob,
There is a Dialog property in the base class that should be used in this case. Change the line to:
Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Progress Telerik
There is a Dialog property in the base class that should be used in this case. Change the line to:
Dim dialog As OpenFileDialog = TryCast(Me.Dialog, OpenFileDialog)Do not hesitate to contact us if you have other questions.
Dimitar
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
