user2113260
user2113260

Reputation: 61

Paste multiple string to TMemo in C++Builder

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!

Upvotes: 0

Views: 270

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597941

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;

Upvotes: 0

Related Questions