0

我在 MS SQL 上有 2 个按 ID 相关的表。Delphi 界面看起来像 2 个 DBGrid。通过从顶部表格中选择一条记录,底部表格显示具有此 ID 的所有记录。DBGrid 连接到一个存储过程 (TMSStoredProc),它只显示具有给定 ID 的所有记录。顶表 AfterScroll 事件:

Bottom_table_SP.ParamByName('@ID').AsInteger := Top_table_SP.FieldByName('ID').AsInteger;
Bottom_table_SP.Active := False;
Bottom_table_SP.Active := True;

一切都很简单,而且很有效。但是当我快速滚动顶部表格时,整个表格开始闪烁 - 顶部表格和底部表格的大小在毫秒内发生变化。有谁知道如何处理这种问题?

4

1 回答 1

1

既然你提到了 SQL Server,我猜你在TADOStoredProcedure这里使用的是 ADO 组件(),所以 normalMasterFieldsMasterSourceproperties 不可用。您仍然拥有其他事物的基本功能,因此您应该使用TDataSet.DisableControlsEnableControls避免这种闪烁:

Bottom_table_SP.DisableControls;
try
  Bottom_table_SP.Active := False;
  Bottom_table_SP.ParamByName('@ID').AsInteger := Top_table_SP.FieldByName('ID').AsInteger;
  Bottom_table_SP.Active := True;
finally
  Bottom_table_SP.EnableControls;
end;

您可能会发现禁用和启用数据显示有助于解释。

于 2013-06-26T17:45:24.850 回答