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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Tab Stops in a RichTextBox

Status
Not open for further replies.

dqrose

Technical User
Mar 17, 2006
24
GB
I'm trying to set tab stops within a RichTextBox; and have tried a solution described by CajunCenturion some time ago, to which I've inserted a link below. It works fine, and I've used it in my code.

thread222-527497

However, whenever I load a rich text document INTO this RichTextBox, it appears that the tab stops revert to their original settings, and I can't seem to reset them to the ones I want. Having said that, when I clear the text in the box, the settings immediately change back to the ones I want! Can anybody tell me what is happening here?

What I want to do is to specify that the tab stops are every fourth character, so that when I load some text into the box which contains tabs, those tabs will be positioned every fourth character (so that for example if the document that has just been loaded has three tabs in succession at the start of the line, the next character will appear in position 12).

Many thanks for any help received.
 
Which is what will happen if you loaded text with tabstops, rather than a rich text document ...
 
Hmmm - I don't think that's it: the text I'm loading is multi-coloured, contains words in both italics and bold, and still retains those characteristics in the RichTextBox. Doesn't that mean that it's being loaded as rich text? But if I'm wrong, can you suggest an alternative way to load it? I don't actually mind losing the colours and other enhancements to the text in the process if it sorts out the tab problem.

The line that actually loads the document into the RichTextBox is:

EditWindow.filename = Full_Path$

where EditWindow is my RichTextBox, and Full_Path$ is the location of the file that I want to load.
 
My comment was in response to "when I load some text into the box which contains tabs, those tabs will be positioned every fourth character"

>Doesn't that mean that it's being loaded as rich text?

Yep, you are loading a Richtext document - and a RichText document contains a full description of how the text looks, including tab stops.

So you need to turn it into text first (load it into a second RTB, then pull the contents of .Text ), then load the .Text of the tabstopped RTB with that text
 
My apologies - I realised immediately after I posted my earlier reply what you meant. Yes, that would do it: many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top