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.
Hello,
I just wanted to mention that Georgi answered with a screenshot and a video file in the provided forum thread. Please take a look if you have not done so.
Did you ever get to the bottom of the carriage returns problem? Please see my other post at http://ko.infragistics.com/community/forums/p/75673/382964.aspx. I created the following workaround to get the correct SelectionStart, but it only works when WordWrap = False:
EditInfo.SelectionStart + Math.Max(EditInfo.GetLineNumber(EditInfo.SelectionStart) - 1, 0)
Thank you. With some tweaks its ok now.
I'll create a bug in our system here for an engineer to take a deeper look into what's causing the selection to get out of whack when break returns are involved.
In the meantime I created a work around in your test project. You'll see the code addition below.
int gndx = 0; void btnFind_Click(object sender, EventArgs e) { int ndx = txtFormatted.Text.IndexOf(txtFind.Text, gndx); if (ndx >= 0) { gndx = ndx + txtFind.Text.Length; txtFormatted.EditInfo.SelectionStart = ndx; txtFormatted.EditInfo.SelectionLength = txtFind.Text.Length; txtFormatted.Select(); if (txtFormatted.EditInfo.GetSelectedValueAsString(true) != txtFind.Text) { while (txtFormatted.EditInfo.GetSelectedValueAsString(true) != txtFind.Text) { gndx -= 1; txtFormatted.EditInfo.SelectionStart = gndx; txtFormatted.EditInfo.SelectionLength = txtFind.Text.Length; txtFormatted.Select(); } gndx = ndx + txtFind.Text.Length; } } else gndx = 0; }
I did not find a way to attach a file here so using the [Insert Media] option. Here is attached a sample project that you can see.
http://community.infragistics.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/86/4721.FormatEditorTest.zip
I think the issue is with <br/> tags. The selection works correctly until first <br/> tag is encountered as per the attached project.