Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse tabs in a RichTextBox
KeywordsRichTextBox, rich text, rtf, tab
CategoriesControls
 
Use the RichTextBox's SelStart and SelLength properties to select the text where you want to define tabs. This program selects all of its text so the tabs are defined for all of the text.

Set the control's SelTabCount property to determine the number of tabs. Then use SelTabs(K) to set the Kth tab using the units of the form or whatever control holds the RichTextBox.

 
Private Sub Form_Load()
Dim i As Integer
Dim X As Single

    ScaleMode = vbPixels

    RichTextBox1.Text = _
        "Title" & vbTab & "Year" & vbTab & "Pages" & _
        ... code deleted ...

    ' Set the tabs.
    RichTextBox1.SelStart = 0
    RichTextBox1.SelLength = Len(RichTextBox1.Text)
    RichTextBox1.SelTabCount = 4
    RichTextBox1.SelTabs(0) = 200
    RichTextBox1.SelTabs(1) = 250
    RichTextBox1.SelTabs(2) = 300
    RichTextBox1.SelTabs(3) = 500

    ' Underline the first line.
    RichTextBox1.SelLength = InStr(RichTextBox1.Text, _
        vbCrLf)
    RichTextBox1.SelUnderline = True
    RichTextBox1.SelLength = 0

    ' Draw the tabs marks.
    AutoRedraw = True
    For i = 0 To RichTextBox1.SelTabCount - 1
        X = RichTextBox1.Left + RichTextBox1.SelTabs(i)
        Line (X, 0)-Step(0, RichTextBox1.Top)
        CurrentX = X
        CurrentY = 0
        Print i
    Next i
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated