Home All Groups Group Topic Archive Search About

Invoking CTRL+C,X,V programatically

Author
1 Apr 2006 5:10 AM
Ori :)
Hi Guys,

I need to be able to perform cop/cut/paste in any textbox of the application
i have focus on USING a button (not key combination). how can I invoke the
^C, ^X and ^V programatically?

I tried something like:
Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As _
                                         System.EventArgs) Handles
btnPaste.Click
        System.Windows.Forms.SendKeys.Send("^(v)")
End Sub

-Didn't work

Any idea?

Thanks!

Author
1 Apr 2006 5:25 AM
Jim Hughes
I wouldn't bother with keystrokes..

Instead look at the System.Windows.Forms.Clipboard class and it's methods.

Show quoteHide quote
"Ori :)" <O**@discussions.microsoft.com> wrote in message
news:1D9888F9-208A-409A-8F1B-4CFF2ACD05CA@microsoft.com...
> Hi Guys,
>
> I need to be able to perform cop/cut/paste in any textbox of the
> application
> i have focus on USING a button (not key combination). how can I invoke the
> ^C, ^X and ^V programatically?
>
> I tried something like:
> Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As _
>                                         System.EventArgs) Handles
> btnPaste.Click
>        System.Windows.Forms.SendKeys.Send("^(v)")
> End Sub
>
> -Didn't work
>
> Any idea?
>
> Thanks!
>
Author
1 Apr 2006 6:53 PM
Herfried K. Wagner [MVP]
"Ori :)" <O**@discussions.microsoft.com> schrieb:
> I need to be able to perform cop/cut/paste in any textbox of the
> application
> i have focus on USING a button (not key combination). how can I invoke the
> ^C, ^X and ^V programatically?
>
> I tried something like:
> Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As _
>                                         System.EventArgs) Handles
> btnPaste.Click
>        System.Windows.Forms.SendKeys.Send("^(v)")
> End Sub

\\\
If TypeOf Me.ActiveControl Is TextBoxBase Then
    DirectCast(Me.ActiveControl, TextBoxBase).Copy()
End If
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>