Private Sub InsertTable(MyRichTextBox As RichTextBox, row As Integer, col As Integer, AutoSize As Boolean, Optional colWidth As Integer = 100) 'row行数,col列数,autosize是否自动列宽,colWidth列宽
Dim rtf As New Text.StringBuilder()
Dim cellWidth As Integer
If AutoSize Then
cellWidth = (MyRichTextBox.ClientSize.Width - 3) / col * 15
Else
cellWidth = colWidth
End If
rtf.Append("{\rtf1")
Dim i As Integer = 0
While i < row
rtf.Append("\trowd")
Dim j As Integer = 1
While j <= col
rtf.Append("\clbrdrt\brdrw15\brdrs")
rtf.Append("\clbrdrl\brdrw15\brdrs")
rtf.Append("\clbrdrb\brdrw15\brdrs")
rtf.Append("\clbrdrr\brdrw15\brdrs")
rtf.Append("\cellx" + (j * cellWidth).ToString())
j += 1
End While
rtf.Append("\intbl \cell \row")
i += 1
End While
rtf.Append("\pard")
rtf.Append("}")
MyRichTextBox.SelectedRtf = rtf.ToString()
End Sub
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交