Results 1 to 6 of 6

Thread: Multiline + Keypress event ?

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Multiline + Keypress event ?

    When I set any textbox to multiline as true , and I use keypress event(I used here Enter key) to move to next control , all the text I wrote there go away , that's only happens while multiline property is on !

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Not sure what you did, but this is what I did (and it works fine):
    Code:
        Private Sub TextBox1_KeyPress(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyPressEventArgs) _
        Handles TextBox1.KeyPress
            If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
                Me.SelectNextControl(TextBox1, True, True, False, True)
            End If
        End Sub

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    No , the problem is still there . I have multiple textboxes in panel, when I used your code , it moves focus to outside the panel to commandbutton . anyways , it's not a big deal . I reset those textboxes to onelined .

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Just wondering if this sort of new bug ?

  5. #5
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    I don't see why you're having this problem, the below works for me whether in a panel or out of one:
    Code:
        Private Sub TextBox1_KeyPress(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.KeyPressEventArgs) _
        Handles TextBox1.KeyPress, TextBox2.KeyPress, TextBox3.KeyPress, _
        TextBox4.KeyPress, TextBox5.KeyPress, TextBox6.KeyPress
            If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
                Me.SelectNextControl(sender, True, True, True, True)
            End If
        End Sub
    Note that for forms with nested controls (e.g. in a panel) you need to set that parameter to True...

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Never mind , I firgured it out myself . thanx for the reply though !

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