Click here to Skip to main content
15,441,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a program that outputs the test results to the array. I want to create a button that would allow users to copy all values from the array (ints) to the clipboard, so when you paste them somewhere, they will be pasted the way they were in the program (column). Like this:

215
234
157
245

It would be ideal if when the user pastes it into Exel, elements would be stored in the column, where is each value stored in the individual cell.

What I have tried:

Tried to use the suggestion from StackOverflow, and the code looks like this:
foreach (object value in trueBenchScoreList)
                clipData.AppendLine(value.ToString());


But it doesn't work as expected
Posted
Updated 6-Feb-22 20:29pm

1 solution

Try:
C#
Clipboard.Clear();
Clipboard.SetText( string.Join("\n", trueBenchScoreList.Select(t => t.ToString())));
 
Share this answer
 
Comments
John Bon Jovy 7-Feb-22 3:57am    
Great! Thank you so much!
OriginalGriff 7-Feb-22 4:25am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900