SelAlignment returns or sets a value that controls the alignment of the paragraphs in a RichEdit control.
SelBullet returns or sets a value that determines if a paragraph in the RichEdit control containing the current selection or insertion point has the bullet style. BulletIndent returns or sets the amount of indent used when SelBullet is set to True.
object.SelAlignment [= variant]
object.SelBullet [= variant]
object.BulletIndent [= variant]
object:RichEdit
The SelAlignment property determines paragraph alignment for all paragraphs that have text in the current selection or for the paragraph containing the insertion point if no text is selected. SelAlignment can be set to basLeftJustify (0), basRightJustify (1), and basCenter (2).
Use the SelBullet property to build a list of bulleted items in a RichEdit control. SelBullet returns and sets a Variant (Long) that determines the bullet style of the paragraph(s). The value is True when the paragraphs in the selection have the bullet style, it is False when not.
The BulletIndent property determines the amount of indent when SelBullet = True. Note, though, that the bullet point does not move with SelBullet, just the text following the bullet point; the bullet point itself is controlled by SelIndent - this is the intended behaviour and not a bug.
These properties returns Null if the selection spans more than one paragraph with different alignments or contains a mixture of bullet and non-bullet styles
OpenW 1 : AutoRedraw = 1
Global Int32 n, rdpos
Ocx RichEdit red = "", 10, 10, 200, 200 : .MultiLine = True : .BorderStyle = 1 : .BulletIndent = 100
Ocx CheckBox chk(0) = "Bullet Points on", 230, 10, 140, 14
Ocx TextBox tb = "", 230, 30, 60, 14 : .BorderStyle = 1 : .ReadOnly = True : Text 297, 31, "Bullet Indent"
Ocx UpDown up : .BuddyControl = tb : .Increment = 200 : .Min = 0 : .Max = 1000 : .Value = red.BulletIndent
Text 230, 54, "Alignment:"
Ocx ComboBox cmb = "", 280, 50, 100, 14 : .Style = 2
cmb.AddItem "Left", 0 : cmb.AddItem "Centre", 2 : cmb.AddItem "Right", 1
For n = 0 To 2
If red.SelAlignment = cmb.ItemData(n) Then cmb.ListIndex = n
Next n
Do : Sleep : Until Me Is Nothing
Sub chk_Click(Index%)
red.SelBullet = chk(0).Value
red.SetFocus
EndSub
Sub cmb_Click
red.SelAlignment = cmb.ItemData(cmb.ListIndex)
red.SetFocus
EndSub
Sub red_Change
If Not IsNothing(chk(0)) Then chk(0).Value = red.SelBullet
EndSub
Sub red_GotFocus
red.SelStart = rdpos
EndSub
Sub red_LostFocus
If Not red Is Nothing Then rdpos = red.SelStart
EndSub
Sub up_Change
red.SetFocus
' red.BulletIndent = up.Value
// BulletIndent just moves the text but not the bullet point
red.SelIndent = up.Value
// SelIndent moved both the bullet point and text.
EndSub
To find if the current selection contains some (but not all) bulleted text, use the following code:
If IsNull(RichEdit1.SelBullet) = True
' Code selection has mixed style.
ElseIf RichEdit1.SelBullet = True
RichEdit1.BulletIndent = 1000
End If
Null differs from zero, these properties can only be queried with IsNull().
RichEdit, SelHangingIndent, SelIndent, SelRightIndent, IsNull
{Created by Sjouke Hamstra; Last updated: 18/12/2015 by James Gaite}