Duplicating Rows from Tables in Richview

General TRichView support forum. Please post your questions here
Post Reply
tomr
Posts: 62
Joined: Wed Dec 09, 2020 9:36 am

Duplicating Rows from Tables in Richview

Post by tomr »

Hi Sergey,
While working with tables in RichEdit, I came across the following issue.
I was not able to reproduce it with a newly created table, so I attached an example RVF file.
Table Example.rvf
(68.01 KiB) Downloaded 14 times
Steps to reproduce:
Open the RichViewActionsTest demo.
Open the attached RVF file.
You should see a table.
Insert a new row.
Copy a complete row and paste it into a column.
Copy.png
Copy.png (2.22 KiB) Viewed 147 times
Insert here.png
Insert here.png (5.77 KiB) Viewed 147 times
After pasting, the column becomes extremely wide. This happens because of the pasted items.
Inserted Column.png
Inserted Column.png (22.23 KiB) Viewed 147 times
Example with a new Created Table
Inserted in New Table.png
Inserted in New Table.png (2.34 KiB) Viewed 147 times
Additionally, is there a proper way to duplicate a row?
If I select the entire row and try to paste, nothing happens.

If you need any more information, please let me know.

Kind regards
Tom
Sergey Tkachenko
Site Admin
Posts: 18128
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Duplicating Rows from Tables in Richview

Post by Sergey Tkachenko »

1. This table has a fixed height, 694 pixels (table.BestWidth = 694).
So, when you insert a wide item in the first column, the second column becomes very narrow, because the table width is not changed.
More natural resizing happens if you turn on automatic calculation of table width (table.BestWidth = 0). In the table properties dialog, select table width = "auto".

2. When you add a new row below or above the selection, it copies attributes of the current row.
Do you want to copy cells contents?
tomr
Posts: 62
Joined: Wed Dec 09, 2020 9:36 am

Re: Duplicating Rows from Tables in Richview

Post by tomr »

Hi Sergey,

Thank you for your quick reply and for the information! 😄

Ah, okay, that helps a lot.
Yes, I just wanted to ask whether it would be possible. If not, that's completely fine.
You can copy the contents individually instead.

Thanks again!
Sergey Tkachenko
Site Admin
Posts: 18128
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Duplicating Rows from Tables in Richview

Post by Sergey Tkachenko »

Tables have methods for copying rows (including cell properties and content).
Saving to TMemoryStream:

Code: Select all

table.SaveRowsToStream(Stream, StartRow_Src, RowCount_Src);
Loading rows from this Stream:

Code: Select all

Table.BeforeLoading(rvlfRVF);
Table.LoadFromStreamEx(Stream, StartRow_Dst, 0, False);
Table.AfterLoading(rvlfRVF);
You must provide that the rows from StartRow_Src to StartRow_Src+RowCount_Src-1 and the rows from StartRow_Dst to StartRow_Dst+RowCount_Src-1 have exactly the same structure (ColSpan and RowSpan properties of cells)
Post Reply