officefileapi-devexpress-dot-xtrarichedit-dot-services-dot-iautocorrectservice-dot-setreplacetable-x28-devexpress-dot-xtrarichedit-dot-autocorrectreplaceinfocollection-x29.md
Provides a table containing input strings and their replacements.
Namespace : DevExpress.XtraRichEdit.Services
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void SetReplaceTable(
AutoCorrectReplaceInfoCollection replaceTable
)
Sub SetReplaceTable(
replaceTable As AutoCorrectReplaceInfoCollection
)
| Name | Type | Description |
|---|---|---|
| replaceTable | AutoCorrectReplaceInfoCollection |
An AutoCorrectReplaceInfoCollection object composed of strings and objects specified to replace those strings.
|
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.Services;
IAutoCorrectService svc = richEditControl1.GetService<IAutoCorrectService>();
if (svc != null)
svc.SetReplaceTable(LoadAbbrevs("abbvs.txt"));
private AutoCorrectReplaceInfoCollection LoadAbbrevs(string path)
{
AutoCorrectReplaceInfoCollection coll = new AutoCorrectReplaceInfoCollection();
string aLine = "";
AutoCorrectReplaceInfo acrInfoIm = new AutoCorrectReplaceInfo(":-)", CreateImageFromResx("smile.png"));
coll.Add(acrInfoIm);
if (File.Exists(path))
{
StreamReader sr = new StreamReader(path);
while (!(sr.EndOfStream))
{
aLine = sr.ReadLine();
if (aLine != "START") continue;
while (!(sr.EndOfStream))
{
aLine = sr.ReadLine();
aLine = aLine.Trim();
string[] words = aLine.Split('=');
if (words.Length == 2)
{
AutoCorrectReplaceInfo acrInfo = new AutoCorrectReplaceInfo(words[0], words[1]);
coll.Add(acrInfo);
}
}
}
sr.Close();
}
return coll;
}
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.Services
Dim svc As IAutoCorrectService = richEditControl1.GetService(Of IAutoCorrectService)()
If svc IsNot Nothing Then
svc.SetReplaceTable(LoadAbbrevs("abbvs.txt"))
End If
Private Function LoadAbbrevs(ByVal path As String) As AutoCorrectReplaceInfoCollection
Dim coll As New AutoCorrectReplaceInfoCollection()
Dim aLine As String = ""
Dim acrInfoIm As New AutoCorrectReplaceInfo(":-)", CreateImageFromResx("smile.png"))
coll.Add(acrInfoIm)
If File.Exists(path) Then
Dim sr As New StreamReader(path)
Do While Not(sr.EndOfStream)
aLine = sr.ReadLine()
If aLine <> "START" Then
Continue Do
End If
Do While Not(sr.EndOfStream)
aLine = sr.ReadLine()
aLine = aLine.Trim()
Dim words() As String = aLine.Split("="c)
If words.Length = 2 Then
Dim acrInfo As New AutoCorrectReplaceInfo(words(0), words(1))
coll.Add(acrInfo)
End If
Loop
Loop
sr.Close()
End If
Return coll
End Function
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetReplaceTable(AutoCorrectReplaceInfoCollection) method.
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.
winforms-richedit-text-autocorrect-feature/CS/Expander/Form1.cs#L26
if (svc != null)
svc.SetReplaceTable(LoadAbbrevs("abbvs.txt"));
#endregion #autocorrectservice
winforms-richedit-text-autocorrect-feature/VB/Expander/Form1.vb#L25
If svc IsNot Nothing Then
svc.SetReplaceTable(LoadAbbrevs("abbvs.txt"))
End If
See Also