Delete item with DEL key

4 posts, 0 answers
  1. Alexander
    Alexander avatar
    18 posts
    Member since:
    Aug 2014

    Posted 14 Jul Link to this post


    I want to achieve that the user can delete the selected item with the DEL key. I have set the 'CanUserDeleteRows' property to true but when I press the DEL key on a selected Item the Deleting, Delete and the KeyDown event aren't fired. I don't want a additional column with delete buttons or a Delete Button beside of the GridView.

    Any idea? My search wasn't successfull....

  2. Alexander
    Alexander avatar
    18 posts
    Member since:
    Aug 2014

    Posted 14 Jul in reply to Alexander Link to this post

    Ah here is my XAML Code, sorry


    <telerik:RadGridView x:Name="gvRecipeDye" Grid.Row="1" Grid.RowSpan="4" Grid.Column="6" ShowGroupPanel="False" IsFilteringAllowed="False"
                         SelectionMode="Single" RowIndicatorVisibility="Collapsed" CanUserInsertRows="True" CanUserDeleteRows="True" CanUserFreezeColumns="False"
                         DataContext="{StaticResource RecipeDyeViewModel}" ItemsSource="{Binding RecipeDye}"
                         Width="300" AutoGenerateColumns="False" NewRowPosition="Bottom" GroupRenderMode="Flat"
                         AddingNewDataItem="gvRecipeDye_AddingNewDataItem" SelectionChanged="gvRecipeDye_SelectionChanged"
                         CellEditEnded="gvRecipeDye_CellEditEnded" SelectionChanging="gvRecipeDye_SelectionChanging" KeyDown="gvRecipeDye_KeyDown">
            <telerik:GridViewDataColumn Name="cColor" Header="Farbe" IsReadOnly="True" CellStyle="{StaticResource GridViewCellStyleColor}" KeyDown="gvRecipeDye_KeyDown"/>
            <telerik:GridViewDataColumn Name="cDyeDescription" Header="Bezeichnung" Width="2*" DataMemberBinding="{Binding DyeName}">
                            <telerik:RadComboBox Name="cbDye"
                                                 DataContext="{StaticResource DyeViewModel}" ItemsSource="{Binding Dye}" Text="{Binding Name}"
                                                 DisplayMemberPath="Name" SelectedValuePath="Id"
                                                 SelectionChanged="cbDye_SelectionChanged" Loaded="cbDye_Loaded"/>
            <telerik:GridViewMaskedInputColumn MaskType="Numeric" Mask="#2,2" Width="1*" Name="cDyeQuantity" Header="Menge (g)"
                                               DataMemberBinding="{Binding DyeQuantity}"/>
                        <telerik:RadButton Content="Delete" IsEnabled="True"
                                           Command="telerik:RadGridViewCommands.Delete" CommandParameter="{Binding}" CommandTarget="{Binding ElementName=gvRecipeDye}"/>

  3. DevCraft R3 2016 release webinar banner
  4. Stefan Nenchev
    Stefan Nenchev avatar
    237 posts

    Posted 18 Jul Link to this post

    Hi Alexander,

    Actually, the default behavior of the RadGridView is to delete the selected item on pressing the DEL button. Can you please update me what is the version of the controls that you are using? In the meantime, you can try subscribing to the PreviewKeyDown event of RadGridView and delete the selected item from the items collection:

    private void clubsGrid_KeyDown(object sender, KeyEventArgs e)
                if (e.Key == Key.Delete)
                    if (clubsGrid.SelectedItem != null)

    Stefan Nenchev
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  5. Alexander
    Alexander avatar
    18 posts
    Member since:
    Aug 2014

    Posted 18 Jul in reply to Stefan Nenchev Link to this post

    So easy...thank you very much!
Back to Top