Click here to Skip to main content
11,715,165 members (61,530 online)
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
Amol011786

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 Sergey Alexandrovich Kryukov 495
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320


Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2015
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