-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
43 lines (36 loc) · 1.85 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Imports DevExpress.XtraRichEdit.API.Native
Imports System.ComponentModel
Imports System.Drawing
Namespace SubDocumentIterator
Public Partial Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
richEditControl1.LoadDocument("template.docx")
End Sub
Private Sub updateFieldsBtn_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
richEditControl1.Document.ForEachSubDocument((Sub(subdoc) subdoc.Fields.Update()))
End Sub
Private Sub removeBookmarksBtn_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
richEditControl1.Document.ForEachSubDocument(Sub(subdoc)
For i As Integer = subdoc.Bookmarks.Count - 1 To 0 Step -1
subdoc.Bookmarks.Remove(subdoc.Bookmarks(i))
Next
End Sub)
End Sub
Private Sub replaceTextBtn_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
richEditControl1.Document.ForEachSubDocument(Sub(subdoc) subdoc.ReplaceAll("test text", "Hello!!!", SearchOptions.None))
End Sub
Private Sub highlightBtn_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
richEditControl1.Document.ForEachSubDocument((Sub(subdoc)
Dim ranges As DocumentRange() = subdoc.FindAll("time", SearchOptions.None)
For Each range As DocumentRange In ranges
Dim cp As CharacterProperties = subdoc.BeginUpdateCharacters(range)
cp.ForeColor = Color.Red
cp.BackColor = Color.Lavender
subdoc.EndUpdateCharacters(cp)
Next
End Sub))
End Sub
End Class
End Namespace