mindrayguowei 发表于 2017-1-9 14:12:30

IncreaseIndent缩进问题

我想要调用TextControl.Selection.IncreaseIndent()来实现首行缩进两格, 但是调用这个方法会导致很多行缩进, 而且缩进的很多. 查看帮助文档只有简单的一句描述:

Increases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method increases the left indent at the text input position. left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.

我看了一下这个tab position是定义在TextControl.ParagraphFormat.TabPositions,但是这个是一个长度为14的数组.

请问我要把TabPositions的值改成什么? 才能实现我一段选中的文字里面的第一行缩进两格.
这个长度为14的数组里面的每个值都代表什么意思? 文档里面没有任何详细的说明, 也找不到相关的demo程序.

gw0506 发表于 2017-1-9 18:04:03

这个和TabPosition应该没有关系,TabPosition是等分宽度的。

TX自带的ParagraphFormatDialog中有首行缩进的设置以及悬挂缩进的设置。但是ParagraphFormat中只有HangingIndent,的确找不到对应的属性设置。
我跟厂商确认一下。

gw0506 发表于 2017-1-9 18:52:38

            TXTextControl.ParagraphFormat firstLineIndent = new TXTextControl.ParagraphFormat();
            firstLineIndent.LeftIndent = 300;
            firstLineIndent.HangingIndent = -300;
            textControl1.Selection.ParagraphFormat = firstLineIndent;

mindrayguowei 发表于 2017-1-10 14:38:57

你这个可以实现一段文字的第一行缩进吗? 怎么确定第一行?

gw0506 发表于 2017-1-10 15:41:38

你试试就知道了。这个其实就是有点取巧,先全部做左缩进,然后把悬挂缩进给个负值,就倒过来成首行缩进了。悬挂缩进和首行所及刚好是反的,一个是第一行短,一个是第一行长。
页: [1]
查看完整版本: IncreaseIndent缩进问题