954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using cut, copy and paste in textbox

Hi masters, i need codes to cut, copy and paste text from textbox.
i know that i can use shortcut like Ctrl + X, Ctrl + C and Ctrl + V, but i need to do it in code.
please help me

Anyhelp will appreciated much

Regards
Ela

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

Use Clipboard...

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

Hi...
Like Sawamura said using clipboard
Try this following procedure, u can call in any event :

Private Sub Cut()
    If Me.Textbox1.Text.Length > 0 Then
        Clipboard.SetDataObject(Me.Textbox1.SelectedText)
        Me.Textbox1.Cut()
    End If
End Sub

Private Sub Copy()
    If Me.Textbox1.Text.Length > 0 Then
        Me.Textbox1.Copy()
    End If
End Sub

Private Sub Paste()
    If Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) Then
        Me.Textbox1.Paste()
    End If
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 
Use Clipboard...


Hi sawamura...
thx for reply, i know that i must use clipboard but i didn't know how to code it.

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

Hi... Like Sawamura said using clipboard Try this following procedure, u can call in any event :

Private Sub Cut()
    If Me.Textbox1.Text.Length > 0 Then
        Clipboard.SetDataObject(Me.Textbox1.SelectedText)
        Me.Textbox1.Cut()
    End If
End Sub

Private Sub Copy()
    If Me.Textbox1.Text.Length > 0 Then
        Me.Textbox1.Copy()
    End If
End Sub

Private Sub Paste()
    If Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) Then
        Me.Textbox1.Paste()
    End If
End Sub


Hi jx_man thx for the reply, i will try ur code now and back to give some feedback

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 
Hi sawamura... thx for reply, i know that i must use clipboard but i didn't know how to code it.


i Think jx_man has a great code in his post.

Sawamura
Junior Poster in Training
69 posts since Nov 2007
Reputation Points: 55
Solved Threads: 6
 

yes, please give a feedback

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

yes, worked perfectly :)

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

Nice to help

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

Hello,
i am working with vs2008 (web application) and I want to copy some content from an excel sheet and and using the clipboard i want to copy the contents in a gridview

I have tried using Clipboard.GetDataObject() but no matter what ever i do it is always returning null so can anyone suggest me solution of how to implement this.

regards,
vamsi.

vamsikrishna20
Newbie Poster
6 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You