var I: integer; while i := 0 to cdsQuery.Recordcount - 1 do begin if DBGrid1.Columns.FieldName = priceP then begin showmessagebox('增加了该列'); end; inc(I); end;
Function F_ExistField( fieldName:String):Boolean;var I:Integer;begin result:=false; for i:=0 to DBGrid1.columns.count-1 do if Ansicomparetext(fieldName, DBGrid1.columns.fieldName)=0 then //ansicomparetext比较,可以处理不区分大小写 begin result:=true; break; end;end;