How can you create a Windows.Forms.Keys that represents Ctrl + V being pressed?

It says in the VS.NET documentation that you can use the bitwiseor to combine enumerated key values to create a key that represents the control key modifier and the V key. I have tried all sorts of ways to do this and I can't get it to work!

Dim kyCtrlV As Windows.Forms.Keys
kyCtrlV = Keys.V  | Keys.Control - doesn't work

basically i am trying to call a ss_Data_KeyUp method that takes a System.Windows.Forms.KeyEventArgs parameter and I want to set the System.Windows.Forms.KeyEventArgs key to by Ctrl V so I can imitate the user pasting data.
LVL 1
BASESLydiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

planoczCommented:
Add this to your form...


    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Const WM_KEYDOWN As Integer = &H100
        Const WM_SYSKEYDOWN As Integer = &H104
        Dim e As System.EventArgs

        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
            Select Case (keyData)
                Case Keys.ControlKey.V
                    'Do something
            End Select
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
0
eozz_2000Commented:
   Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.Control Then
            If e.KeyCode = Keys.V Then
                MsgBox("Ctl + v")
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim r As KeyEventArgs
        r = New KeyEventArgs(r.Modifiers.Control Or Keys.V)
        Me.TextBox1_KeyDown(Me.TextBox1, r)
    End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eozz_2000Commented:
In that way you create a KeyEventArgs that has the control set to True and the keyCode of V

I hope this could help you :)
0
Bob LearnedCommented:
SendKeys.Send("^{V}")

Bob
0
BASESLydiaAuthor Commented:
r = New KeyEventArgs(r.Modifiers.Control Or Keys.V)
That did it! Thank you so much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.