Page 1 of 1

Show a column by scrolling

Posted: Mon May 27, 2024 11:52 am
by j&b
Hello,
I am working with Delphi 7.1 and tRichView v21.3.

I have a table in a memo that extends over the right border of the memo.
In the visible area of the memo are the first 20 (of 40 table) columns.
Now I would like to jump to the 30th column via a switch ('Which column should be jumped to?').
However, the table should be scrolled so that the jumped column is visible.
Who can help me?

Re: Show a column by scrolling

Posted: Tue May 28, 2024 11:57 am
by j&b
I think I have found a solution.
I only had to insert the option ‘sbHscrollClick(Self);’ twice.

If you know a ‘better’ solution, please write.
I also found the procedure ‘Scroll2selection’ by Sergey. However, I still can't get it to work with my code.
(At the end of my procedure, which copies the content of a source column into any target column, the target column should automatically be displayed in the ‘normal’ memo).


Translated with DeepL.com (free version)


procedure TForm1.Scroll2selection; //von Sergey
var RVData: TCustomRVFormattedData; //CRVFData, CRVData, Math;
StartItemNo, StartOffs, EndItemNo, EndOffs: Integer;
i, StartDItemNo, StartDOffs, EndDItemNo, EndDOffs: Integer;
R: TRect;
begin
// finding subdocument containing selection (a main document or a cell)
RVData:= memo.RVData;
while RVData.GetChosenRVData<>nil do
RVData := TCustomRVFormattedData(RVData.GetChosenRVData);
// getting selection
RVData.GetSelectionBoundsEx(StartItemNo, StartOffs, EndItemNo, EndOffs, True);
if (StartItemNo<0) or (EndItemNo<0) then
exit;
// converting selection position from item indices to drawing item indices
RVData.Item2DrawItem(StartItemNo, StartOffs, StartDItemNo, StartDOffs);
RVData.Item2DrawItem(EndItemNo, EndOffs, EndDItemNo, EndDOffs);
// (roughly) calculating selection coordinates in local coordinates of RVData
with RVData.DrawItems[StartDItemNo] do
R := Bounds(Left, Top, Width, Height);
for i := StartDItemNo+1 to EndDItemNo do
with RVData.DrawItems do begin
R.Left := Min(R.Left, Left);
R.Top := Min(R.Top, Top);
R.Right := Max(R.Right, Left+Width);
R.Bottom := Max(R.Bottom, Top+Height);
end;
// scrolling to the selection
RVData.ShowRectangle(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
end;