This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
Form1.vb
79 lines (64 loc) · 2.9 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Imports DevExpress.XtraBars.Ribbon
Imports System
Imports System.Drawing
Imports DevExpress.XtraRichEdit.API.Native
Namespace TextBoxes
Partial Public Class Form1
Inherits RibbonForm
Public Sub New()
InitializeComponent()
richEditControl1.LoadDocument("FloatingObjects.docx")
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
CreateTextBox(richEditControl1.Document)
ResizeTextBox(richEditControl1.Document)
ColorTextBox(richEditControl1.Document)
EditTextBoxContent(richEditControl1.Document)
End Sub
Private Sub CreateTextBox(ByVal document As Document)
' #Region "#create"
Dim myPosition As DocumentPosition = document.Paragraphs(0).Range.Start
'Insert a text box to a given position
Dim myTextBox As Shape = document.Shapes.InsertTextBox(myPosition)
' #End Region ' #create
End Sub
Private Sub EditTextBoxContent(ByVal document As Document)
' #Region "#editcontent"
'Access the text box content
Dim textBoxDocument As SubDocument = document.Shapes(0).TextBox.Document
'Insert text to the text box
textBoxDocument.AppendText("Multimodal, Stochastic Symmetries for E-Commerce")
'Apply formatting to the text box content
Dim cp As CharacterProperties = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range)
cp.ForeColor = Color.DarkSlateGray
cp.FontName = "Times New Roman"
cp.FontSize = 18
textBoxDocument.EndUpdateCharacters(cp)
' #End Region ' #editcontent
End Sub
Private Sub ColorTextBox(ByVal document As Document)
' #Region "#changecolor"
Dim myTextBox As Shape = document.Shapes(0)
'Specify the background color
myTextBox.Fill.Color = Color.MistyRose
'Draw a border around the text box
myTextBox.Line.Color = Color.DarkGray
myTextBox.Line.Thickness = 1.5F
' #End Region ' #changecolor
End Sub
Private Sub ResizeTextBox(ByVal document As Document)
' #Region "#resize"
Dim myTextBox As Shape = document.Shapes(0)
'Resize the text box
myTextBox.ScaleX = 5F
myTextBox.ScaleY = 1F
'Set the horizontal alignment
myTextBox.HorizontalAlignment = ShapeHorizontalAlignment.Center
myTextBox.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Margin
'Change the vertical alignment
myTextBox.VerticalAlignment = ShapeVerticalAlignment.Top
myTextBox.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Margin
' #End Region ' #resize
End Sub
End Class
End Namespace