private void button35_Click_1(object sender, EventArgs e)
        {

            Clipboard.SetDataObject(textBox1.Text, true);
        }

This lets me copy only the text in textbox1

How do i make it so that it copies the text in textbox1 and textbox2 and textbox3 e.t.c ?

Recommended Answers

All 2 Replies

Try something like this:

string concat="";
foreach (Control ct in Controls)
   if (ct is TextBox)
        concat = (ct as TextBox).Text + "\r\n"+concat;
//this puts a CRLF in between each YMMV

(It seems that the foreach is iterating through the controls backwards -- I double checked that they were added in the .designer file in the right order so there must be some reason for it -- so I just adjusted the concatenation order)

thanks !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.