Is there a way to set the column width in percentage?
I have 3 columns in the table, I want to set 60% with for 1st, 20% for 2nd column, 20% for 3rd column.
Thank you very much!
Table column width in percentage
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Table column width in percentage
In TRichView/ScaleRichView, like in HTML, widths of columns are calculated by widths of its cells.
To assign widths in percentage, use negative values of Cell.BestWidth:
Defining widths of one cell in each column is enough. But the user may edit this document and delete a row containing these cells, so it's better to assign the same BestWidth to all cells in the given column.
In RichViewActions, there is a table properties dialog where users can define widths of the selected table cells.
If you define width of all (actually, even of one) column in percentage, the table will occupy the full page size (as if its width = 100%).
You can define the proper table width by assigning table.BestWidth (in percentage, or in pixels/twips).
To assign widths in percentage, use negative values of Cell.BestWidth:
Code: Select all
table.Cells[0, 0].BestWidth := -60;
table.Cells[0, 1].BestWidth := -20;
table.Cells[0, 2].BestWidth := -30;
In RichViewActions, there is a table properties dialog where users can define widths of the selected table cells.
If you define width of all (actually, even of one) column in percentage, the table will occupy the full page size (as if its width = 100%).
You can define the proper table width by assigning table.BestWidth (in percentage, or in pixels/twips).
-
- Posts: 4
- Joined: Mon Feb 19, 2018 6:05 pm
Re: Table column width in percentage
Thanks. It works.