Event for Delete Button Click

2 posts, 0 answers
  1. Olga
    Olga avatar
    14 posts
    Member since:
    Mar 2011

    Posted 27 Jun 2011 Link to this post


    What event is called when I press the Delete key on my keyboard on one of the items in the tree? I need to know because I need to make sure that the item is not only removed from the visual tree, but also from my Database where that item is. What event is called when I press the delete key?

    Is there anything that can help me create shortcuts for Adding an Item to the tree for example? I tried making my own shortcuts by exposing the keyDown event in the TreeListView, but the event is only hit when I double click an item in the tree and start typing.
    this is what I tried to do:
    private void TreeListView_KeyDown(object sender, KeyEventArgs e)
           if (e.Key == Key.Delete)
              menuWithButtons_DeleteTaskClick(null, null);   // another method is called, in which i delete the item from the DB




    I couldn't make it work so that a person can select an item, press 'a' key, and have another item added to the tree. Is there a way to do that?

    I hope there is a way because I also want to make copy and paste work, and it's not just going to be a copy and paste of the text on the tree item, but of the whole item that is stored in my DB and associated with that title in the tree.


  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 01 Jul 2011 Link to this post

    Hello Olga,

     The RadTreeListView is handling the Key.Down, that is why you may not receive a notification on this button key down event.

     I have prepared sample application that enables you to handle the Del key (or any other key) using CustomKeyboardProvider.

    Further more if would like press 'a' key, and have some custom logic executed on the RadGridView, then you may create your own custom Command and use it on 'a' press:

    else if (key == Key.A)
                   commandsToExecute.Add(new CustomCommand() { ItemsSource = this.parentTreeListView.ItemsSource as IList });

    public class CustomCommand:ICommand
               public IList ItemsSource { get; set; }
               public bool CanExecute(object parameter)
                   return true;
               public event System.EventHandler CanExecuteChanged;
               public void Execute(object parameter)
                   ItemsSource.Add(new Club("sample name", DateTime.Now, 1));

    May you please have a look at the attachment and let us know if you have any further questions?
      All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top