CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    How to make TAB key work for RichTextBox Control ?

    Hi,

    How can we make TAB key work for a Rich Text Box Control. I have set the properties TabStop = False, still it is not working.

    Regards

    RM



  2. #2
    Join Date
    Dec 1999
    Location
    Dallas, Texas, USA
    Posts
    59

    Re: How to make TAB key work for RichTextBox Control ?

    I know this looks stupid, but it is the only way I have found and noone has told me different..


    Dim bTABHit as Boolean

    private Sub RichTextBox1_KeyDown(KeyCode as Integer, Shift as Integer)
    If KeyCode = 9 then
    bTABHit = true

    iStart = RichTextBox1.SelStart

    If iStart = 0 then
    RichTextBox1.Text = vbTab & RichTextBox1.Text
    else
    strText = RichTextBox1.Text
    RichTextBox1.Text = mid(strText, 1, iStart) & vbTab & mid(strText, iStart + 1, len(strText) - iStart)
    End If
    RichTextBox1.SelStart = iStart + 1

    End If
    End Sub

    private Sub RichTextBox1_LostFocus()
    If bTABHit then
    bTABHit = false
    RichTextBox1.SetFocus
    End If
    End Sub




    --
    Chizl
    [email protected]
    http://www.chizl.com/

  3. #3
    Join Date
    Nov 1999
    Location
    Texas
    Posts
    2

    Re: How to make TAB key work for RichTextBox Control ?

    Try this...

    Private Sub RichTextBox1_KeyDown(KeyCode as Integer, Shift as Integer)

    If KeyCode = vbKeyTab then

    RichTextBox1.SelText = vbKeyTab
    KeyCode = 0

    End if

    End Sub

    Tim.


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

Featured