Paste multiple string to TMemo in C++Builder

212 views Asked by At

I have a vector of Strings from a TListView control. I want to copy them to the clipboard, then paste them into a TMemo control such that each line from the list is on a separate line in the TMemo. Everything I've tried so far pastes as a single line. But copy/paste multiple lines within the TMemo itself works just fine. Ideas?

Thanks!

1

There are 1 answers

1
Remy Lebeau On

Use the RTL's sLineBreak constant instead of individual chars:

String s;
BOOST_FOREACH(String str, strings) {
    s += (str + sLineBreak);
}

Also, you should be using the TClipboard::AsText property instead of the TClipboard::SetTextBuf() method:

cb->AsText = s;