A routine to insert tables in Richtextbox
This is a routine that add a table to the current selection in a RichTextBox. I didn't find how can I do this on the web, so I made it by looking on the rtf Specification. I expect that this would be helpfull for those who are using RTB. If you find how to fix the problems i found please send me your work. (Sorry for my english ;) )
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Public Sub InsertTable(Rtb as RichTextBox, vRows as integer,vCols as integer)
Dim A As String, i As Integer, j As Integer
A = "{\rtf1\ansi\ansicpg1252\deff0" & _
"{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}" & _
"\viewkind4\uc1\trowd\trqc\trgaph108\trleft-8" & _
"\trbrdrt\brdrs\brdrw10" & _
"\trbrdrl\brdrs\brdrw10" & _
"\trbrdrb\brdrs\brdrw10" & _
"\trbrdrr\brdrs\brdrw10"
For i = 1 To vCols
A = A & "\clbrdrt\brdrw15\brdrs" & _
"\clbrdrl\brdrw15\brdrs" & _
"\clbrdrb\brdrw15\brdrs" & _
"\clbrdrr\brdrw15\brdrs" & _
"\cellx" & _
CStr((ScaleX(Rtb.Width, Rtb.Parent.ScaleMode, vbTwips) \ vCols * 2) * i) & _
"\clbrdrt"
Next
A = A & "\pard\intbl\lang3082\f0\fs24"
For i = 1 To vRows
A = A & "\intbl\clmrg"
For j = 1 To vCols
A = A & "\cell"
Next
A = A & "\row"
Next
A = A & "}"
Rtb.SelText = A
End Sub
Original Comments (3)
Recovered from Wayback Machine