This is a migrated thread and some comments may be shown as answers.

Reseting Image to nothing implementation

2 Answers 71 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
OD
Top achievements
Rank 1
OD asked on 23 Feb 2017, 09:52 AM

Hello,

I'm using Q1 2017 radcontrols for winforms (vb.net).

I have a radporama with a radtile, and a radpropertygrid, with the radtile as selectedobject.

When i set an image to the radtile using the radpropertygrid, everything works fine. But i dont know how to reset the image to nothing. If i select the image in the radpropertygrid, and the press "delete" on my keyboard, nothing happens.

I need a solution without clicking on the square and reset.

Could you help me?

Thanks in advance.

 

Best regards.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Feb 2017, 01:23 PM
Hello Jean-Marc,

Thank you for writing.  

In order to handle the case when the user hits the Delete key while the editor is active for the Image property, it is necessary to subscribe to the EditorInitialized event and handle the RadBrowseEditorElement.TextBoxItem.PreviewKeyDown and reset the property value:
Sub New()
    InitializeComponent()
    Me.RadPropertyGrid1.SelectedObject = Me.RadTileElement1
    Me.RadPropertyGrid1.ToolbarVisible = True
    AddHandler Me.RadPropertyGrid1.EditorInitialized, AddressOf EditorInitialized
End Sub
 
Private Sub EditorInitialized(sender As Object, e As Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs)
    Dim editor As PropertyGridBrowseEditor = TryCast(e.Editor, PropertyGridBrowseEditor)
    If editor IsNot Nothing Then
        Dim el As RadBrowseEditorElement = TryCast(editor.EditorElement, RadBrowseEditorElement)
        AddHandler el.TextBoxItem.PreviewKeyDown, AddressOf TextBoxPreviewKeyDown
    End If
End Sub
 
Private Sub TextBoxPreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
    If e.KeyData = Keys.Delete Then
        Dim item As PropertyGridItem = TryCast(Me.RadPropertyGrid1.SelectedGridItem, PropertyGridItem)
        If item IsNot Nothing Then
            item.ResetValue()
            Me.RadPropertyGrid1.EndEdit()
        End If
    End If
End Sub

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
OD
Top achievements
Rank 1
answered on 23 Feb 2017, 01:51 PM

Thank you.

Everything works fine.

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