TForm1 = class(TForm) DBGrid1: TDBGrid; ADOQuery1: TADOQuery; DataSource1: TDataSource; procedure ADOQuery1AfterOpen(DataSet: TDataSet); private { Private declarations } procedure DoGetText(Sender: TField; var Text: string; DisplayText: Boolean); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DoGetText(Sender: TField; var Text: string; DisplayText: Boolean);begin Text := TField(Sender).Value; if Trim(Text) <> '' then begin Text := StringReplace(Text, '1', '东', [rfReplaceAll, rfIgnoreCase]); Text := StringReplace(Text, '2', '南', [rfReplaceAll, rfIgnoreCase]); Text := StringReplace(Text, '3', '西', [rfReplaceAll, rfIgnoreCase]); Text := StringReplace(Text, '4', '北', [rfReplaceAll, rfIgnoreCase]); end;end;procedure TForm1.ADOQuery1AfterOpen(DataSet: TDataSet);var I: Integer;begin for I := 0 to DBGrid1.FieldCount -1 do if DBGrid1.Fields.FieldName = 'A' then DBGrid1.Fields.OnGetText := DoGetText;end;