在创建窗口时,对需要进行数据库连接的控件进行初始化,或者在数据模块中,非常有用

ComponentCount--组件数量

for i:=0 to ComponentCount-1 do   //对窗口组件进行遍历

begin

  if self.Components[i] is TFDQuery then

  begin

    (self.Components[i] as TFDQuery).Connection:=Conn;

    (self.Components[i] asTFDQuery).FetchOptions.Mode:=fmAll;

  end else

  if self.Components[i] is TFDStoredProc then

  begin

    (self.Components[i] as TFDStoredProc).Connection:=Conn;

  end else

  if self.Components[i] is TDBGridEh then

  begin

    (self.Components[i] as TDBGridEh).EvenRowColor:=clWindows;

    (self.Components[i] as TDBGridEh).OddRowColor:=$00FDFDF4;

  end;

end;

 

上一篇:P1059 [NOIP2006 普及组] 明明的随机数


下一篇:2022.2.1-----leetcode.1763