RadListbox copy selecteditem

2 posts, 0 answers
  1. herb
    herb avatar
    23 posts
    Member since:
    Oct 2018

    Posted 24 Dec 2019 Link to this post

    Have a RadListbox, in xaml have set (SelectionMode="Multiple").

    Want the user able to copy a selected item(s) and paste it anywhere (text file, excel, etc.) having issue finding topics in forum that helps me complete the operation of "copy".

    Is there a method to do this?

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2360 posts

    Posted 26 Dec 2019 Link to this post

    Hello Herb,

    RadListBox doesn't provide a built-in clipboard support. To achieve your requirement, you can subscribe to the KeyDown event of the listbox and implement a custom copy/paste logic that saves and loads data from the clipboard.

    private void RadListBox_KeyDown(object sender, KeyEventArgs e)
    {
    	var selectedItems = this.listBox.SelectedItems;
    	if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.C)
    	{
    		// implement a copy logic that saves the selected items in the clipboard                
    	}
    	else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.V)
    	{
    		// implement a paste logic that loads the data from the clipboard
    	}
    
    	// you can use the Clipboard class to implement copy/paste operations
    	// https://docs.microsoft.com/en-us/dotnet/api/system.windows.clipboard?view=netframework-4.8
    }

    I hope this helps.

    Regards,
    Martin Ivanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top