Questions tagged [textrange]

Represents a selection of content between two TextPointer positions.

The TextRange class introduces the following terminology.

Selection - A TextRange is a selection of content between two positions indicated by TextPointers. One of these positions a fixed anchor with respect to the selection, while the other position is movable. This is similar to how a selection made by a user using the mouse or keyboard behaves.

Current Selection - Because a TextRange always indicates a selection in content, it makes sense to simply refer to the selection indicated by a TextRange as the current selection.

Text Container - A text container is the element that forms the ultimate border for the flow content at hand; the selection indicated by a TextRange always falls within a text container. Currently, a text container must be either a FlowDocument or a TextBlock. Document - The content collectively contained within a text container is referred to as a document. For more information about other related terms like position, see TextPointer.

92 questions
101
votes
4 answers

Get a range's start and end offset's relative to its parent container

Suppose I have this HTML element:
Hello everyone! This is my home page

Bye!

And the user selects "home" with his mouse. I want to be able to determine how many characters into #parent his selection starts…
Tom Lehman
  • 85,973
  • 71
  • 200
  • 272
45
votes
5 answers

Highlight text range using JavaScript

I would like to highlight (apply css to) a certain text range, denoted by its start and end position. This is more diffucult than it seems, since there may be other tags within the text, that need to be…
Vincent
  • 1,126
  • 2
  • 10
  • 11
20
votes
1 answer

Javascript: Move caret to last character

I have a textarea and when I click in it I want to move the caret to the last character so Something[caret] function moveCaret(){ // Move caret to the last character } As I know…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
10
votes
1 answer

How to insert inline content from one FlowDocument into another?

I'm building an application that needs to allow a user to insert text from one RichTextBox at the current caret position in another one. I spent a lot of time screwing around with the FlowDocument's object model before running across this technique…
Robert Rossney
  • 94,622
  • 24
  • 146
  • 218
9
votes
3 answers

TextRange offsetLeft and offsetTop broken in Internet Explorer 8 Standards Mode (IE8)

I seem to have found an issue with Internet Explorer 8, when finding the position of a Text Range - For instance the currently selected text. I have not found been able to find any reports of this issue on StackOverflow or…
8
votes
2 answers

Set specific text to bold in WPF RichTextBox

I am extending the functionality of a WPF Richtextbox. I want certain text to become bold when I type it in. I was able to get certain text to bold but the text following the bolded word would also become bolded... Heres a sample of my code: private…
SILENT
  • 3,916
  • 3
  • 38
  • 57
7
votes
4 answers

How can I change the font color of a TextRange in PowerPoint from C#?

I created a PowerPoint presentation using C#: PowerPoint.Application powerpointApplication; PowerPoint.Presentation pptPresentation; PowerPoint.Slide Slide; // Create an instance of PowerPoint. powerpointApplication = new…
pesten
  • 71
  • 1
  • 1
  • 2
7
votes
1 answer

Is there a way selecting MULTIPLE areas of text with JS in Chrome and/or IE?

Firefox 3 can select MULTIPLE areas of text with JS. Is there a way doing this in Chrome and IE? I really tried to find a way to select of multiple textareas in a web page in Chrome and IE9. Infos at: http://help.dottoro.com/ljxsqnoi.php Example…
Klaus Klose
  • 71
  • 1
  • 2
5
votes
5 answers

How to know if there is a link element within the selection

In Javascript, I'd like determine whether an element, say an A element, exists inside a given range/textRange. The aim is to determine if the user's current selection contains a link. I am building a rich text editor control. The range object has…
thomasrutter
  • 114,488
  • 30
  • 148
  • 167
4
votes
1 answer

getting offsetLeft of a text range

Can anyone tell me why this code is returning undefined. I was hoping this would give the left coordinate of the user selected text. function alertRangeObject(){ var userSelection; if(window.getSelection) { userSelection =…
Jeff
  • 3,943
  • 8
  • 45
  • 68
4
votes
1 answer

Inserting text into an editable IFRAME at the caret position (IE)

I'm struggling with an actually straighforward problem: In Internet Explorer I want to insert plain text at the current caret position. This works really fine for simple TEXTAREA elements but it doesn't entirely work for editable IFRAMEs, which is…
Andreas Pasch
  • 125
  • 1
  • 9
4
votes
2 answers

Find start/end character index of animation in a textbox within powerpoint

Here is a screenshot of some example slide. I have an animation on the word "Pizza". I am trying to find where in the string this occurs by character number. My code to grab information about the animations: foreach (PowerPoint.Effect effect in…
Parris
  • 17,833
  • 17
  • 90
  • 133
3
votes
2 answers

How to concatenate multiple FlowDocuments together into 1 FlowDocument

I have multiple FlowDocuments that I would like to concatenate together. The method below doesn't have a return statement. What I would like to do is to turn the TextRange back into a FlowDocument. private FlowDocument Concatenate(FlowDocument…
B4ndt
  • 576
  • 2
  • 7
  • 15
3
votes
1 answer

Why does this function fail if there is any formatting in the text? [in IE8]

I am using the method below to search for a string in a web page. It matches plain text; but, it fails in the following context: I am searching for text If I search for "am searching" it will match.. But if I search for "I am…
Exception
  • 8,111
  • 22
  • 85
  • 136
3
votes
1 answer

'SolidBrush' parameter type is not valid for formatting property 'Foreground'. Parameter name: value

I try change color text RickTextBox wpf in invoke method . But i get some trouble . My trouble is 'SolidBrush' parameter type is not valid for formatting property 'Foreground'. Parameter name: value My code MethodInvoker action = delegate { …
jonny
  • 165
  • 3
  • 13
1
2 3 4 5 6 7