Also, I found out adding new row to table is very cpu intensive, to the point where whole GUI stutters for a moment while code that adds new row executes. This is how I add it:
Code: Select all
table := frmDebug.rvLog.RVData.GetItem(0) as TRVTableItemInfo;
if table.RowCount = 0 then
begin
table.InsertRows(0, 1, -1, FALSE);
table.InsertCols(0, 3, -1, FALSE);
table.Rows[0].Items[0].BestWidth := 75;
table.Rows[0].Items[1].BestWidth := 75;
end
else
table.InsertRows(table.RowCount, 1, 0, FALSE);
frmDebug.rvLog.Format;
table.Cells[table.RowCount - 1, 0].Clear;
table.Cells[table.RowCount - 1, 1].Clear;
table.Cells[table.RowCount - 1, 2].Clear;
table.Cells[table.RowCount - 1, 0].AddFmt('%s', [time_str], 0, 0);
table.Cells[table.RowCount - 1, 1].AddFmt('%s', [type_str], tstyle, 1);
table.Cells[table.RowCount - 1, 2].AddFmt('%s', [AData], dstyle, 2);
frmDebug.rvLog.Format;
frmDebug.rvLog.VScrollPos := frmDebug.rvLog.VScrollMax;
And this is how I create table (in OnCreate even of the form):
Code: Select all
table := TRVTableItemInfo.CreateEx(0, 0, rvLog.RVData);
with table do
begin
BorderWidth := 0;
CellVPadding := 0;
CellBorderWidth := 0;
CellVSpacing := 0;
BorderVSpacing := 0;
Color := clNone;
BestWidth := 0;
Options := [rvtoRTFAllowAutofit];
end;
rvLog.AddItem('ContentTable', table);
Is there way to optimize this?