Insert a table Using RichTextBox

Source: Internet
Author: User

Properties-all sizes are in twips
XLeft-Position of the left edge of the table
IsCentered-Set to True to center the table
Rows-Sets or returns the number of rows in the table
Columns-Sets or returns the number of columns in the table
Row-An Array of Rows (1 to Rows)
Column-An Array of columns (1 to Columns)
Column (I). xWidth-Width of the ith column
Cell-A 2-d Array of Cells (1 to Rows, 1 to Columns)
Cell (r, c). Contents-Sets or returns the contents of the cell

Methods
InsertTable (RTB As RichTextBox)-Inserts the table into the RichTextBox
At the currrent cursor position.

Code:
Http://www.applevb.com/RTFtable.zip

Example:

Option Explicit

Dim RTFtable As clsRTFtable
Private Declare Function LockWindowUpdate () Function LockWindowUpdate Lib "user32 "(_
ByVal hwndLock As Long _
) As Long

Private Sub commandementclick ()
Dim I As Integer
Set RTFtable = New clsRTFtable
'Stop flicker
Call LockWindowUpdate (RichTextBox1.hWnd)

For I = 1 To 5
With RTFtable
'Set the size of the table
. Columns = 3
. Rows = 2
'Fill the cells
'Row 1
. Cell (1, 1). Contents = "Row 1"
. Cell (1, 2). Contents = "Column2"
. Cell (1, 3). Contents = "Column3"

'Row 2
. Cell (2, 1). Contents = "Row2"
. Cell (2, 2). Contents = "R2C2"
. Cell (2, 3). Contents = "R2C3"
'Do we want to center it on the page?
. IsCentered = True

'Insert the table at the current cursor postion
. InsertTable RichTextBox1
End
Next I
Call LockWindowUpdate (0)

End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.