|
-
Feb 24th, 2004, 06:39 AM
#1
Thread Starter
New Member
copy and paste to clipboard method
Hi fellas...
So I'm doing this copy and paste to clipboard coding. It's running fine though. Below are the codes.
VB Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCopy.Click
Clipboard.SetDataObject(txtSource.Text, False)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPaste.Click
txtDest.Text = Clipboard.GetDataObject.GetData(DataFormats.Text, True)
End Sub
There is no problem for pasting from clipboard. The copy code is running fine but as you can see we can only have text from text box named txtSource. How about if we like to copy from any highlighted word. Maybe we should change the txtSource into some other commands perhaps or maybe to call another function.
Hope you all can give me some tips. Thanx in advance...
-
Feb 24th, 2004, 07:47 AM
#2
This code will copy any text which has been selected, or all of the textbox's text if no words have been selected...
VB Code:
If (txtSource.SelectionLength > 0) then
clipboard.SetDataObject (mid(txtSource.Text, _
txtSource.SelectionStart, txtSource.SelectionLength).ToString)
Else
clipboard.SetDataObject (txtSource.Text)
End if
-
Feb 25th, 2004, 11:03 AM
#3
Thread Starter
New Member
Well that is not exactly what I had in mind. What I meant by any higlighted words are like highlighting at the web page, the ms word, notepad etc. So basically what you mentioned is all about the same text box. And what I meant is anything that is highlighted. But thanx anyway....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|