Catching carrage return

I am trying to catch the carrage return with this code I found on net but doesn't seem to work. Nothing happens.
Is there another way to do it



If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
 


Wayne




Answer this question

Catching carrage return

  • Kmicic77

    I just added a break point in the cbbURL_KeyPress and the return does not call this routine. Do you think I should post a bug report or do you think others have reported it


  • John Walker



    If e.KeyChar = ControlChars.Cr Then

     


  • Yura Developer

    A combo box



    Private Sub cbbURL_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cbbURL.KeyPress

     




  • Sunny9001

    Its not a bug, you need to create a derived control and override the Control.IsInputKey method.


    protected override bool IsInputKey(Keys keyData)
    {
       if ((keyData & Keys.KeyCode) == Keys.Enter)
       {
          return true;
       }
       
       return base.IsInputKey(keyData);
    }

     



    Protected Overrides Function IsInputKey(ByVal keyData As Keys) As Boolean
       
       If ((keyData And Keys.KeyCode) = Keys.Enter) Then
          Return True
       End If
       
       Return MyBase.IsInputKey(keyData)

    End Function

     

    Once you have done that the KeyPress event should be raised on ENTER.



  • CPB


    Wayne

    At times you have to check for Chr (10 ) too .

    Shasur



  • RKN_India

    Which event are you using this from

  • Jin17

    what calls the protected overrides function   i have included a break in this function, but it is never called...
  • BladeWise

    Sorry guys neither one worked. I am using vbexpress beta 2 do you think it might be a bug in it



  • Subhash Bhave

    Thanks David,
    I am new to vb net so I don't know anything about derived controls and overiding but am about to find out.
    Thanks again,


  • Vishwanatha Nagur

    You could try


    If e.KeyChar = (vbcrlf) Then
     

  • Catching carrage return