vb .net - Rich TextBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deviranir
    New Member
    • Dec 2008
    • 6

    vb .net - Rich TextBox

    Hi,

    I am very thankful to the authors for the replies i received for my earlier posts.
    Now i have a new question.

    In my windows application, i have a rich textbox. When i press Enter, i want some action to be performed. But now it simply goes to the next line.

    Any help will be appreciated.

    Thanks,
    Dev.
  • truezplaya
    New Member
    • Jul 2007
    • 115

    #2
    Events

    Look in to the events of the RTB control

    truez

    Comment

    • raids51
      New Member
      • Nov 2007
      • 59

      #3
      yea just create an event to handle the keypress, correct me if im wrong but i think you might need to override something

      Comment

      • Xennex
        New Member
        • Jan 2009
        • 7

        #4
        One solution

        You could try using the PreviewKeyDown event of the RTB and check for vbCRLF (vbNewLine is an equivalent).

        Code:
            Private Sub RichTextBox1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles RichTextBox1.PreviewKeyDown
                If e.KeyValue = vbNewLine Then
                    ...
                End If
            End Sub

        Comment

        • MrMancunian
          Recognized Expert Contributor
          • Jul 2008
          • 569

          #5
          Why all the difficult suggestions? This should be quite basic stuff right? :)

          Code:
          Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
          Select Case e.KeyCode
            Case Keys.Return
              'Perform action
            End Select
          End Sub
          Steven

          Comment

          Working...