| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | C# .NET |
| Version: | 1.0 |
| Released: | April 24, 2007 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control .NET with C# .NET |
| Download code: | tx_getpagetext.zip |

Generally, the powerful Selection class can be used to retrieve text or manipulate parts of a document.
Sometimes, however, it is necessary to retrieve the text at a specific position, without previously selecting it - this avoids flickering and cursor displacement.
TX Text Control offers sophisticated classes in order to get the character index position from a specific location. This can be used to retrieve the string at the current mouse position or similar tasks.
In this sample, we are going to calculate the page bounds using the page size, the gap between the pages in the PageView ViewMode and the page margins.
The diagram above illustrates how to calculate the start position and the end position of the current page. Using the TextChar.GetItem() method and the calculated location, it is possible to retrieve the character index positions of these points.
int startValue = textControl1.TextChars.GetItem(new Point(xValue, yValue), true).Number;
These indexes are used with the .NET String.SubString() method with the complete text of the TextControl instance to get the partial text between these two locations.
string PageText = textControl1.Text.Replace("\r\n", "\n").Substring _ (startValue - 1, endValue - (startValue - 1));
The minimum requirements for this sample application are TX Text Control .NET 13.0 trial version and Visual Studio 2005.