Reseting Image to nothing implementation

3 posts, 1 answers
  1. QuizzBox
    QuizzBox avatar
    65 posts
    Member since:
    Jan 2011

    Posted 23 Feb Link to this post

    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. Answer
    Dess
    Admin
    Dess avatar
    2107 posts

    Posted 23 Feb Link to this post

    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.
  3. QuizzBox
    QuizzBox avatar
    65 posts
    Member since:
    Jan 2011

    Posted 23 Feb Link to this post

    Thank you.

    Everything works fine.

Back to Top