AutoCorrectEventArgs.AutoCorrectInfo Property
Gets or sets the AutoCorrectInfo object that provides methods to analyze input text and contains a replacement object.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.RichEdit.v19.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
AutoCorrectInfo | An AutoCorrectInfo object. |
Remarks
The AutoCorrectInfo is the main source of information used in handling the AutoCorrect event.
The following code sample shows how to handle the RichEditControl.AutoCorrect event to replace the typed $ symbol with a picture of a dollar, and substitute the text enclosed in percent symbols with custom content.
Use the AutoCorrectEventArgs.AutoCorrectInfo
property to obtain the document text, then call the AutoCorrectInfo.DecrementStartPosition method to expand its left boundary until a special symbol or a word separator symbol is found. Use the AutoCorrectInfo.ReplaceWith property to pass a replacement object (a string or an image) to the document if a resulting string meets certain conditions, such as whether it is a dollar sign or a %date% string.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-handle-the-autocorrect-event-e3041
Private Sub richEditControl1_AutoCorrect(ByVal sender As Object, ByVal e As DevExpress.XtraRichEdit.AutoCorrectEventArgs) Handles richEditControl1.AutoCorrect
Dim info As AutoCorrectInfo = e.AutoCorrectInfo
e.AutoCorrectInfo = Nothing
If info.Text.Length <= 0 Then
Return
End If
Do
If Not info.DecrementStartPosition() Then
Return
End If
If IsSeparator(info.Text(0)) Then
Return
End If
If info.Text(0) = "$"c Then
info.ReplaceWith = CreateImageFromResx("dollar_pic.png")
e.AutoCorrectInfo = info
Return
End If
If info.Text(0) = "%"c Then
Dim replaceString As String = CalculateFunction(info.Text)
If Not String.IsNullOrEmpty(replaceString) Then
info.ReplaceWith = replaceString
e.AutoCorrectInfo = info
End If
Return
End If
Loop
End Sub
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AutoCorrectInfo property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.