Hello,
I'm having trouble using the UltraSpellChecker with an UltraFormattedTextEditor control when the text of the control has multiple lines.
I want to use the ContextMenu option and have the user select from the list of suggestions. I am using NetAdvantage version 7.2 with Visual Studio 2005. I modified the "Simple Spell Checking VB" sample, which is included. The problem seems to be with UltraSpellChecker.GetErrorAtPoint(). When you right-click on an error in the first line, everything is fine. But when you right-click on an error in any other line, the UltraWinSpellChecker.StartIndex that's returned from GetErrorAtPoint() is off by one character. If you try it with three lines, it will be off by two characters. This makes is impossible to replace the mispelling with the suggestion.
It looks like it's counting the carriage return-newline as two characters, rather than one. The funny thing is that the red squiggly line is displayed correctly for the error (see SimpleSpellChecking.jpg in attached project). But if you step through the code, you'll see that the StartIndex for the error is not correct (see Watch.jpg in attached project).
This seems like a bug, but I wanted to make sure I'm doing everything correctly, which is why I attached, the modified sample project.
Can someone please help with this? If you need any further info just let me know.
Thanks,
Sean.
I just verified that I get the same behavior with the latest version 2010 vol 1.
I guess I'll need to submit a fix request?
This problem is still occurring on version 2011 vol 2.
Here is a workaround in case it helps anybody:
Private Sub FindAndReplaceErrorWord(ByVal fte As UltraFormattedTextEditor, ByVal offsetLeft As Int16, ByVal suggestion As String)
fte.EditInfo.SelectionStart =
Me.lastClickedError.StartIndex - offsetLeft
fte.EditInfo.SelectionLength =
Me.lastClickedError.EndIndex - Me.lastClickedError.StartIndex + 1
If fte.EditInfo.Editor.SelectedText = Me.lastClickedError.CheckedWord Then
fte.EditInfo.Editor.SelectedText = suggestion
Else
offsetLeft += 1
FindAndReplaceErrorWord(fte, offsetLeft, suggestion)
End If
End Sub