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

RadListbox copy selecteditem

1 Answer 187 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
herb
Top achievements
Rank 1
Veteran
Iron
herb asked on 24 Dec 2019, 05:15 PM

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 26 Dec 2019, 11:21 AM

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.
Tags
ListBox
Asked by
herb
Top achievements
Rank 1
Veteran
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or