Home > Back-end >  Questions about rolling StringGrid cell contents
Questions about rolling StringGrid cell contents

Time:09-19

To achieve a StringGrid, a cell content is too long, want to realize rolling the cell contents, starting from the first character scroll until the last one, and then again and again so, I don't know how to implement, or any other form controls can implement this function, be obliged!

CodePudding user response:

If the column width is very narrow, all over the screen scrolling text user experience is not good, and to compare cost resources, usually words than column width, will be displayed when the mouse on a tip box, shows the complete content of the field,
Scrolling text there are two ways: one is through the characters, in front of one of the most dynamic delete cell simulation rolling effect, this method is simple, but not smooth,
Second, by drawing the cell contents, more smooth, this example only draw the selected cell:
 
Implementation
{$R *. DFM}
Var
Ps: integer=0;
procedure TForm1.FormCreate(Sender: TObject);
The begin
Timer1. Interval:=10;
Timer1. Enabled:=True;
end;
Procedure TForm1. Timer1Timer (Sender: TObject);
Var
StrText: string;
The rect: TRect;
CV: TCanvas;
The begin
StrText:='content of cells;
The rect:=StringGrid1 CellRect (StringGrid1. Selection. The TopLeft. X, StringGrid1. Selection. The TopLeft. Y);
The rect. Left:=the rect. Left + 3;
The rect. Top:=the rect. Top + 5;
CV:=TCanvas. Create;
CV. Handle:=GetwindowDC (StringGrid1. Handle);
Try
CV. The Font. Color:=clred;
CV. TextRect (the rect, the rect. Left + ps, the rect. Top + 2, strText);
Inc (ps);
If ps & gt; CV. TextWidth (strText) * 2 then
Ps:=- CV. TextWidth (strText);
The finally
ReleaseDC (StringGrid1. Handle, CV. Handle).
CV. Free;
end;
end;

CodePudding user response:

Can dynamically () when the mouse to click the cell, the cell into a Memo, in this way, you can through the contents of the Memo cell (too long),

CodePudding user response:

When MouseOver shows a Hint or good
  • Related