Results 1 to 4 of 4

Thread: CTRL + C keypress on a Datagrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    12

    CTRL + C keypress on a Datagrid

    Hi,
    I wish to capture the keypress event for a datagrid. I have added the handlers for the Keypress and Keydown for the textbox of each column. Problem is that the modular keys (Control, shift and ATL) are handled by the keydown and the 'C' key is handled by the keypress. How can i get the combination code for this so that i can write my copy routine.

    Thanks in advance.

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277
    Try this in the _KeyDown event
    VB Code:
    1. 'This shows you how to trap when certain keys are pressed
    2.         If e.KeyCode.Equals(Keys.Enter) = True Then
    3.             lblPressed.Text = "you pressed: Enter"
    4.         ElseIf e.KeyCode.Equals(Keys.F10) = True Then
    5.             lblPressed.Text = "you pressed: F10"
    6.         Else
    7.             lblPressed.Text = e.KeyCode.ToString
    8.         End If
    ~Peter


  3. #3
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Unhappy

    It appears that i have not solved the problem. The e. in the _KeyDown event doesn't appear to hold more than one keydown event at a time.

    Sorry.
    ~Peter


  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Here's one way that investiages which bits are set in the modiferkeys property of the control object:

    Code:
        Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If (Control.ModifierKeys And Keys.Shift) > 0 And (Control.ModifierKeys And Keys.Control) > 0 Then
                If e.KeyCode = Keys.A Then
                    MessageBox.Show("Shift + Control + A")
                End If
            End If
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width