Results 1 to 4 of 4

Thread: 'attaching' a button to a textbox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    'attaching' a button to a textbox

    Why does this not worK? I'm trying to trap the 'enter' key when pressed but debugging shows me that chr(13) isn't detected.
    VB Code:
    1. Private Sub tab_2_txtSearchByPhone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
    2.     Handles tab_2_txtSearchByPhone.KeyPress
    3.         'Purpose : Detects when the Enter button is pressed.
    4.         If e.KeyChar = Chr(13) Then
    5.             e.Handled = True
    6.             GetHistory(RemoveChar(tab_2_txtSearchByPhone.Text, "-"c), True)
    7.         End If
    8.     End Sub
    Last edited by Andy; Jul 26th, 2004 at 01:49 PM.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Seems like that should work - I copied and pasted your code, then added a message box, and the message box pops up.

    VB Code:
    1. If e.KeyChar = Chr(13) Then
    2.             e.Handled = True
    3.             'GetHistory(RemoveChar(tab_2_txtSearchByPhone.Text, "-"c), True)
    4.             MessageBox.Show("You pressed enter.")
    5.         End If

  3. #3
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    you chould try

    VB Code:
    1. If e.KeyValue = 13 Then
    2.             e.Handled = True
    3.             MessageBox.Show("You pressed enter.")
    4.         End If

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    now i'm confused. It works for me too in a dummy app. i am using a custom textbox. I'll have to open up the source code to see if chr(13) is blocked.

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