I am using UltraFormattedTextEditor that internally stores the formats in HTML.
the normal text editor has function like Select(start index, length) but there is no similar function in Formatted text editor. Hence, I am using following.
txtEditor.EditInfo.SelectionStart = index;
txtEditor.EditInfo.SelectionLength = find.Length;
Actually I am implementing find and replace feature. So when user finds a word, it needs to highlight (select) that word. So, I should be finding withing .Text property and not .Value property. Because .value property may find something within the html formatting text as well. So, once we find a word within .Text property and use its index/length for the EditInfo - it does not display it correctly (may be because the EditInfo is trying to select within the Value property).
So, I am not clear as to what should be the right approach here.
Here's how it displays on my end with the tests I've ran.
This boils down to two possible ideas left.
1) Something is incorrect in your implementation that causes a shift in the selection area. Can you post any code snippets of how you're implementing a highlight selection?
2) There was a previous mention of this issue occurring one other time, but reproducing the issue has been unsuccessful. If you have a sample project that demonstrates this, I can have the team take a closer look at the issue?
I have version 2010.3.
I am not denying that replace does not work. Its a correct code - but I am pointing out at how the control displays the selected text.
Do you have a sample project that I could run? Also, what version of the controls are you using?
The code snippet above was tested in versions 2010.2 and the upcoming 2011.1.
The issue is how the editor looks when selection is made. When we set the SelectionStart and SelectionLength property, the editor shows some different text selected instead of the one we intend to.
E.g. if the text as "god bless america and eveyone else goes nuts" and you intend to select the word 'bless' - the editor shows 'ss ame' as selected (just an example).
When I replace the text it does it correctly, but the the selection display is not correct.
I'm not sure of your exact question here, but it looks like you're on the right track with your thought process. Below I pasted a snippet of code that might help with your creation of a Search/Replace dialog for the editor.
//Find and select the string value string findme = "brown"; int startindex = 0; formattedTextEditor.Value = "The quick <u>brown fox</u> jumped over the lazy dogs."; formattedTextEditor.EditInfo.SelectionStart = formattedTextEditor.Text.IndexOf(findme, startindex); formattedTextEditor.EditInfo.SelectionLength = findme.Length; //Replace the selected string with the string "red" string replacement = "red"; formattedTextEditor.EditInfo.Delete(); formattedTextEditor.EditInfo.InsertValue(replacement);