Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 VB.NET
I have 2 multiline textboxes in windows application, textbox1 and textbox2. I have data on both textboxes. I also have copy and paste button on form.
If i select textbox1 selected data and clicks on copy button ...then it should copy data that is selected and now i goto next textbox textbox2 and click on "paste".then it should paste the data that was selected from textbox1.
And in the same way for textbox2 to textbox1 data should be copied and paste....
Please suggest.....
Posted 22-Dec-12 23:28pm
Amol011634

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There are a couple of ways you can do this:
1) You could use the actual windows clipboard: Clipboard.GetText[^] and Clipboard.SetText[^] are the easiest way to do it.
Or
2) You could create a class level string variable to hold the information. This is pretty easy, just copy the text in and out. Use this way if you don't want to disturb the actual clipboard content for other applications.
 
Either way, you just need to read the data out using the TextBox.SelectedText property and either set it it in the other TB, or set the TextBox.Text property if you want it to replace all the text.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 428
1 Sergey Alexandrovich Kryukov 283
2 PhilLenoir 115
3 RajeeshMenoth 110
4 Peter Leow 100
0 Sergey Alexandrovich Kryukov 6,465
1 OriginalGriff 5,926
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,540


Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100