Class

Range


Description

Used to get the starting position, length, and end position of a StyleRun.

Properties

Name

Type

Read-Only

Shared

EndPosition

Integer

Length

Integer

StartPosition

Integer

Property descriptions


Range.EndPosition

EndPosition As Integer

The ending position of the StyleRun.

This property is read-only.


Range.Length

Length As Integer

The length of the StyleRun.


Range.StartPosition

StartPosition As Integer

The starting position of the StyleRun. The first position is zero.

Notes

A StyleRun is a series of characters with the same style attributes in a StyledText object. A block of StyledText can be thought of as a group of StyleRuns that are appended to each other. Use the Range class to access the position of a StyleRun within the styled text.

Sample code

The following example loops through the StyleRuns in a block of StyledText that is displayed in a TextArea. It uses the StartPos and Length properties of the Range class to get the position of each StyleRun and displays it and the text of each StyleRun in a ListBox.

Var count As Integer
count = TextArea1.StyledText.StyleRunCount  ' get the number of StyleRuns
For i As Integer = 0 To count - 1
  ListBox1.AddRow(TextArea1.StyledText.StyleRunRange(i).StartPos.ToString)
  ListBox1.CellTextAt(i, 1) = Str(TextArea1.StyledText.StyleRunRange(i).Length)
  ListBox1.CellTextAt(i, 2) = TextArea1.StyledText.StyleRun(i).Text
Next

Compatibility

All project types on all supported operating systems.

See also

Object parent class; Paragraph, StyledText, StyleRun classes; DesktopTextArea control.