Tab stop position

  • Thread starter Thread starter Stanley
  • Start date Start date
S

Stanley

Hi all! Can somebody tell me how to customize the tab stop position in
a rich text box? Just like we do in MS Word by clicking the ruler! I've
been searching the web but I can't find the answer! Please help me,
thanks in advance!
 
If you set a few tab stops in WordPad, the result might look like
this:

---snip---
{\rtf1\ansi\ansicpg1252\deff0\deflang1030{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
{\*\generator Msftedit
5.41.15.1507;}\viewkind4\uc1\pard\tx1704\tx2840\tx4544\f0\fs20 abc\tab
def\tab ghi\tab jkl\par
}
---snip---

The tab definitions in the example above are "tx1704\tx2840\tx4544".

Look up the RTF 1.5 specification for more details.

For some inspiration, have a look at this sample program:
http://www.codeproject.com/richedit/rulerricheditctrl.asp

Download the source and look at the "Do..." methods in the
file "RulerRichEditCtrl.cpp", esp. "DoIndent" where you will
find an interesting constant named "PFM_TABSTOPS.

Googling for this brings us to http://tinyurl.com/bhzon

Fill out the PARAFORMAT2 structure correctly and send it to
the RichText control and you should be in business.

Perhaps there is already a .Net implementation/wrapper for this?

Otherwise you will have to take one of the many RichEdit
wrapper samples out there and extend it with the required
functionality.

Would be nice if Microsoft provided a decent wrapper out of the box.
The current wrapper is next to useless.

Hope any of this helps point you in the right direction, though
I am sure it is not what you were hoping for.

Joergen Bech
 
Stanley said:
Can somebody tell me how to customize the tab stop position in
a rich text box? Just like we do in MS Word by clicking the ruler!

\\\
Private Sub Form1_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Load
Me.RichTextBox1.Text = _
"Hallo" & ControlChars.Tab & _
"Welt" & ControlChars.Tab & _
"Bla"
End Sub

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
Me.RichTextBox1.SelectAll()
Me.RichTextBox1.SelectionTabs() = _
New Integer() {100, 200, 300}
End Sub
///
 
\\\
Private Sub Form1_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Load
Me.RichTextBox1.Text = _
"Hallo" & ControlChars.Tab & _
"Welt" & ControlChars.Tab & _
"Bla"
End Sub

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
Me.RichTextBox1.SelectAll()
Me.RichTextBox1.SelectionTabs() = _
New Integer() {100, 200, 300}
End Sub
///

Ah! So it already has been wrapped. Sorry about my original
answer. It was not incorrect as to what needed to be sent to
the control (.SelectionTabs does the same thing), but ...

Did some work with the RichText control half a year ago.
Had some problems setting and getting formatting information
in the cases where the current selection would span multiple
formattings and I needed to change just one aspect of the
formatting across the whole selection. I believe this is still a
problem in VS2005. Guess I just still had a sour taste in my
mouth from that experience.

I need to learn to look before I leap.

/JB
 
Thanks all for spending your precious to help me! Thank JB, thank
Herfried!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top