Ashlar
Ashlar

Reputation: 676

Managing paragraph Tab settings in a tRichEdit - Delphi

I am working with a tRichEdit component and using a tSpinedit to determine tab spacings using the trichedit.oncreate event to generate an array of tab positions to begin with. This is working fine and each new paragraph I generate uses the defined tab spacing. However, when using the SpinEdit1 Change event, I can change the tab spacing for the paragraph of text in which the cursor is placed, but it is not performing across the whole richedit text.

Is there a way to apply new tabstop settings across all of the paragraphs in a richedit document?

When I change the tab settings using tForm1.SpinEdit1Change, the tabs change for the current paragraph and subsequent ones, but previous paragraphs remain as they were. Is there a way to iterate through the paragraphs in the richedit1 content to change all of them in a 'for' loop? I have not found any array or list in the properties. Is there a property for setting the tabs globally at runtime or another approach that will accomplish this?

Upvotes: 2

Views: 2168

Answers (1)

Tom Brunberg
Tom Brunberg

Reputation: 21033

Select all paragraphs (from the very beginning to the end of the document) before setting the tab positions. You can select all paragraphs either manually, or programmatically with

RichEdit1.SelectAll;

Ref. documentation: Vcl.ComCtrls.TCustomRichEdit.Paragraph

Paragraph formatting information includes alignment, indentation, numbering, and tabs.

Paragraph is a read-only property, because a TCustomRichEdit object has only one TParaAttributes object, which cannot be changed. The attributes of the current paragraphs, however, can be changed, by setting the properties of the TParaAttributes object.

The current paragraphs are the paragraphs that contain the selected text. If no text is selected, the current paragraph is the one containing the cursor.

Upvotes: 5

Related Questions