A newer version of this page is available. Switch to the current version.

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.v18.2.Core.dll


public AutoCorrectInfo AutoCorrectInfo { get; set; }

Property Value

Type Description

An AutoCorrectInfo object.


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.

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
    End If
        If Not info.DecrementStartPosition() Then
        End If

        If IsSeparator(info.Text(0)) Then
        End If

        If info.Text(0) = "$"c Then
            info.ReplaceWith = CreateImageFromResx("dollar_pic.png")
            e.AutoCorrectInfo = info
        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
        End If
End Sub
See Also