第一个问题:
如何调用stringgrid中不可见的部分?你需要滚动才能看到它.
例如:
stringgrid中有20行,但一次只能看到10行.你需要滚动查看其他10.如何调用"隐藏"的?
第二个问题:
我知道这可能不是正确的方法,所以一些指针将不胜感激.
我有一个带有1个固定行的字符串网格.我在运行时添加ColorButtons.所以我用按钮填充1列.我用这个按钮来"插入/删除"行.只要所有网格都处于"可见"部分,就可以正常工作.当我"插入"新行并将按钮移动到"隐藏"部分时出现问题.然后将最后一个按钮绘制到Cell [0,0]."隐藏"部分中的其他按钮被正确绘制.知道为什么会这样吗?我应该找到一种在OnDraw方法中管理此问题的方法,还是有更好(正确)的方法来执行此操作?
码:
procedure Tform1.addButton(Grid : TStringGrid; ACol : Integer; ARow : Integer);
var
bt : TColorButton;
Rect : TRect;
index : Integer;
begin
Rect := Grid.CellRect(ACol,ARow);
bt := TColorButton.Create(Grid);
bt.Parent := Grid;
bt.BackColor := clCream;
bt.Font.Size := 14;
bt.Width := 50;
bt.Top := Rect.Top;
bt.Left := Rect.Left;
bt.Caption := '+';
bt.Name := 'bt'+IntToStr(ARow);
index := Grid.ComponentCount-1;
bt :=(Grid.Components[index] as TColorButton);
Grid.Objects[ACol,ARow] := Grid.Components[index];
bt.OnMouseUp := Grid.OnMouseUp;
bt.OnMouseMove := Grid.OnMouseMove;
bt.Visible := true;
end; …Run Code Online (Sandbox Code Playgroud)