Difference between revisions of "Range"

From Xojo Documentation

m
m
Line 6: Line 6:
 
{{Description
 
{{Description
 
|text = Used to get the starting position, length, and end position of a [[StyleRun]]. }}
 
|text = Used to get the starting position, length, and end position of a [[StyleRun]]. }}
 
 
 
  
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
Line 15: Line 12:
 
{{Property | name=StartPos | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The starting position of the StyleRun. The first position is zero. }}
 
{{Property | name=StartPos | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;The starting position of the StyleRun. The first position is zero. }}
 
</dynamicTable>
 
</dynamicTable>
 
  
 
==Notes==
 
==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 [[StyleRun|StyleRuns]] that are appended to each other. Use the '''Range''' class to access the position of a [[StyleRun]] within the styled text.
 
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 [[StyleRun|StyleRuns]] that are appended to each other. Use the '''Range''' class to access the position of a [[StyleRun]] within the styled text.
 
  
 
==Examples==
 
==Examples==
Line 25: Line 20:
  
 
<rbcode>
 
<rbcode>
Dim count, i as Integer
+
Dim count As Integer
count=TextArea1.StyledText.StyleRunCount  //get the number of StyleRuns
+
count = TextArea1.StyledText.StyleRunCount  // get the number of StyleRuns
For i=0 to count-1 //loop through them
+
For i As Integer = 0 To count - 1
ListBox1.Addrow Str(TextArea1.StyledText.StyleRunRange(i).StartPos)
+
  ListBox1.AddRow(Str(TextArea1.StyledText.StyleRunRange(i).StartPos))
ListBox1.Cell(i,1)=Str(TextArea1.StyledText.StyleRunRange(i).Length)
+
  ListBox1.Cell(i, 1) = Str(TextArea1.StyledText.StyleRunRange(i).Length)
ListBox1.Cell(i,2)=TextArea1.StyledText.StyleRun(i).Text
+
  ListBox1.Cell(i, 2) = TextArea1.StyledText.StyleRun(i).Text
 
Next
 
Next
 
</rbcode>
 
</rbcode>
 
  
 
==See Also==
 
==See Also==

Revision as of 17:55, 3 August 2017

Class (inherits from Object)

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

Properties
EndPos fa-lock-32.png Length StartPos

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.

Examples

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.

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

See Also

Paragraph, StyledText, StyleRun classes; TextArea control.