for i := 0 to form1.ControlCount - 1 do
  if (form1.Controls[i] is TDBEdit) or (form1.Controls[i] is TDBGrid) then
       flag:=true;

解决方案 »

  1.   

    for i := 0 to (ComponentCount - 1) do
      if (Components[i] is TDBedit) or (Components[i] is TDBgrid) then
       .....................
      

  2.   

    for i := 0 to ComponentCount - 1 do
      begin
        if (Components[i] is TDBEdit) then
          TEdit(Components[i]).ReadOnly := True;
        if (Components[i] is TDBGrid) then
          TMemo(Components[i]).ReadOnly := True;
       
      end;
      

  3.   

    楼上的办法是判断dbgrid和dbedit的吧……要看有db属性的控件恐怕的判断控件是否有datasource这个属性了。