Results 1 to 4 of 4

Thread: [RESOLVED] another Enter key event question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Location
    Oklahoma
    Posts
    83

    Resolved [RESOLVED] another Enter key event question

    When the enter key is pressed, I would like to have <br /> added to the end of a each line in multiline textbox then allow me to type next line. Then repeat for each line.

    using Code:
    1. Private Sub TextBox_Body_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox_Body.KeyDown
    2.         If e.KeyCode = Keys.Enter Then
    3.             TextBox_Body.Text = TextBox_Body.Text + "<br />"
    4.         End If
    5.     End Sub

    works ok for single line. Does however insert a blank line above current text and cursor is at start of second line containing text.

    Make sense?

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: another Enter key event question

    vb.net Code:
    1. Public Class Form1
    2.  
    3.     Private Sub TextBox_Body_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox_Body.KeyDown
    4.         If e.KeyCode = Keys.Enter Then
    5.             TextBox_Body.Text = TextBox_Body.Text & "<br />"
    6.             TextBox_Body.SelectionStart = TextBox_Body.TextLength
    7.         End If
    8.     End Sub
    9.  
    10. End Class

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Location
    Oklahoma
    Posts
    83

    Re: another Enter key event question

    Wow Thanks...Works PERFECT

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: another Enter key event question

    Quote Originally Posted by whatwasithinking View Post
    Wow Thanks...Works PERFECT
    Welcome

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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