Page 1 of 1

Control the width of table columns programmatically

Posted: Thu Dec 11, 2025 9:50 pm
by Vitalii
Hi, I have a specific question about tables.

The editor has a TRVTableItemInfo table that contains TRVLabelItemInfo.

According to the program logic, I programmatically change TRVLabelItemInfo.Text twice. The first time, the width of the table columns automatically adapts to the wide text, which is normal. But when I change the text to a shorter one the second time, the width of the table columns remains large (automatic adjustment does not work). If I then edit something in the table with the cursor, the columns return to the correct sizes. How can I restore the width of the columns programmatically after the second change to TRVLabelItemInfo.Text?

All operations take place within TSRichViewEdit.CanUpdate := False .. True.

Re: Control the width of table columns programmatically

Posted: Sat Dec 27, 2025 7:16 am
by Vitalii
The sequence of actions is as follows:

1. The table contains content (text) that changes programmatically.
2. The content increases > the table columns expand.
3. The content decreases > the table columns remain wide.
4. Task: adjust the width of the columns to the current size of the content

I wanted to save the table settings before the changes and restore them after the changes. But I couldn't find a method or property that is responsible for the exact width of the table columns. But it would be enough to simply change something “in the background” in the table to update the width of the columns, as happens when I edit the table manually.

Re: Control the width of table columns programmatically

Posted: Sat Dec 27, 2025 12:03 pm
by Sergey Tkachenko
In order to help, I need to know how you change content size in code.
Please send me a code fragment or (better) a simple project reproducing the problem.

Re: Control the width of table columns programmatically

Posted: Sat Dec 27, 2025 1:23 pm
by Vitalii
The content in the table changes via TRVLabelItemInfo.Text:

Code: Select all

SRichViewEdit.CanUpdate := False;
try
  ALabel.Text := '<some large text>'; // <-- here the table extends (expected behavior)
  { other operations... }
  ALabel.Text := 'A'; // <-- here, the table width should return to normal (but it doesn't)
finally
  SRichViewEdit.RVHeader.Reformat;
  SRichViewEdit.RichViewEdit.Reformat;
  SRichViewEdit.RVFooter.Reformat;
  SRichViewEdit.CanUpdate := True;
end;

Re: Control the width of table columns programmatically

Posted: Tue Dec 30, 2025 12:29 pm
by Sergey Tkachenko
I confirm the problem.
It will be fixed in the next update.
As a workaround, call ALabel.UpdateMe immediately after changing ALabel.Text.

Re: Control the width of table columns programmatically

Posted: Tue Dec 30, 2025 5:30 pm
by Vitalii
Thanks, it works.