Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you get the tab key to tab text, not go to next tab index. rtf

Status
Not open for further replies.

Brawn

Programmer
Jul 5, 2001
73
0
0
CA
Hi,

I have a Rich Text Box on a Form
But when u press the Tab Key (vbKeyTab) it changes focus to the next tab index (like its suppossed to).

How can I get it to tab the text? (vbTab)

[neutral] Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
See if there is a property for the rich text box that affects tab behavior. If not you will have to resort to capturing the key stroke and manually handling it (absorb the key stroke by setting the keycode = 0, add the ascii value of tab to the text in the rich text box).
 
(the problem with inserting vbTab into text is you need to know where the cursor is)

I found a solution in the msdn help.

Code:
Private Sub rtfMemo_GotFocus()
    Dim Control As Control
   
    On Error Resume Next 'for controls w/out tabstop
   
    For Each Control In Controls
        Control.TabStop = False
    Next Control
End Sub
Private Sub rtfMemo_LostFocus()
    Dim Control As Control
    
    On Error Resume Next
   
    For Each Control In Controls
        Control.TabStop = True
    Next Control

End Sub

Thanks though steveblum
[smile] Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
Is there a reason thet you don't want to set the "TabStop" property for that Rich Text box to False?
 
try

Code:
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
  Select Case KeyCode
    Case vbKeyTab
      RichTextBox1.SelText = vbTab
      KeyCode = 0
  End Select
End Sub
 
HEy,

THaT wOrks grEat JusTin,

THanKs Brawn

"My mind is my Shrine,
and my body the Temple around it."

-The difference between genius and stupidity is that genius has its limits-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top