Reputation: 33
hi i created a little app for my business. Now i have a little problem. I want to paste one code of textbox2 to textbox4 without erasing previous data of textbox4..
I tried these codes but it doesn't work
for copy==>
private void button3_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBox2.Text);
}
for paste ===>
private void button6_Click(object sender, EventArgs e)
{
textBox4.Text =Clipboard.GetText()+Environment.NewLine;
}
this paste code is overwriting. I want a method for paste button to keep previous data when pasting new data..
Help me plz
Upvotes: 2
Views: 127
Reputation: 5453
For pasting the new value without removing the old text, you can do it like below in your button6
click event :
private void button6_Click(object sender, EventArgs e)
{
textBox4.Text += Clipboard.GetText() + Environment.NewLine;
}
Upvotes: 0
Reputation: 218818
Because you're setting the value of the text:
textBox4.Text = ...
If you only want to append the value, use the +=
operator:
textBox4.Text += ...
Or, more explicitly:
textBox4.Text = textBox4.Text + ...
Upvotes: 8