Windows 窗体 RichTextBox 控件具有许多选项,用于设置其所显示的文本的格式。 可以通过设置 SelectionBullet 属性将所选段落的格式设置为项目符号列表。 还可以使用 SelectionIndent、SelectionRightIndent 和 SelectionHangingIndent 属性来设置段落相对于控件的左右边缘以及其他文本行的左边缘的缩进。
将段落的格式设置为项目符号列表
将 SelectionBullet 属性设置为
true
。RichTextBox1.SelectionBullet = True
richTextBox1.SelectionBullet = true;
richTextBox1->SelectionBullet = true;
缩进段落
将 SelectionIndent 属性设置为一个整数,表示控件左边缘与文本左边缘之间的距离(以像素为单位)。
将 SelectionHangingIndent 属性设置为一个整数,该整数表示段落中第一行文本的左边缘与同一段落中后续行的左边缘之间的距离(以像素为单位)。 SelectionHangingIndent 属性的值仅适用于在第一行下方换行的段落中的行。
将 SelectionRightIndent 属性设置为一个整数,表示控件右边缘与文本右边缘之间的距离(以像素为单位)。
RichTextBox1.SelectionIndent = 8 RichTextBox1.SelectionHangingIndent = 3 RichTextBox1.SelectionRightIndent = 12
richTextBox1.SelectionIndent = 8; richTextBox1.SelectionHangingIndent = 3; richTextBox1.SelectionRightIndent = 12;
richTextBox1->SelectionIndent = 8; richTextBox1->SelectionHangingIndent = 3; richTextBox1->SelectionRightIndent = 12;
注释
所有这些属性都会影响包含所选文本的任何段落,以及当前插入点之后键入的文本。 例如,当用户在段落中选择一个单词,然后调整缩进时,新设置将应用于包含该单词的整个段落,以及随后在选定段落后输入的任何段落。 有关以编程方式选择文本的信息,请参阅 Select。