Click here to Skip to main content
12,898,174 members (57,113 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.0 C# VB 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

1 solution

Rate this: bad
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.
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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

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