指定properties属性后,打开事件列表,就可看到procedure TForm1.cxGrid1DBTableView1Column1PropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); begin if DisplayValue='' then begin ErrorText := 'A不可空白'; Error := True; end; end;
在A字段的事件OnValidate if trim(sender.asstring) = '' then//注意A字段的类型 begin showmessage('请填写A'); abort; end;
procedure TForm2.ADOTable1AValidate(Sender: TField); begin if trim(sender.asstring) = '' then//注意A字段的类型 begin showmessage('请填写A'); abort; end; end;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
begin
if DisplayValue='' then
begin
ErrorText := 'A不可空白';
Error := True;
end;
end;
if trim(sender.asstring) = '' then//注意A字段的类型
begin
showmessage('请填写A');
abort;
end;
procedure TForm2.ADOTable1AValidate(Sender: TField);
begin
if trim(sender.asstring) = '' then//注意A字段的类型
begin
showmessage('请填写A');
abort;
end;
end;
在TField的OnValidate只会在写入数据时,触发这个检查。
在cxGrid层面处理,不会这样。
前面不是已经给出答案,让你写在column.properties.onvalidate事件里