tfield的字段名和显示名
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls; type TForm1 = class(TForm) btn1: TButton; edt1: TEdit; edt2: TEdit; ds1: TDataSource; qry1: TADOQuery; con1: TADOConnection; dbgrd1: TDBGrid; btn2: TButton; edt3: TEdit; edt4: TEdit; edt5: TEdit; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject); begin with qry1 do begin Close; sql.Text:= 'select * from dbo.TB_xxxx'; open; end; qry1.First; edt1.Text:= qry1.Fields[0].Text; edt2.Text:= qry1.Fields[0].Value; qry1.Fields[0].DisplayLabel:= '编号嘿嘿'; edt3.Text:= qry1.Fields[0].DisplayText;//readonly edt4.Text:= qry1.Fields[0].DisplayLabel;//ok显示编号嘿嘿这个名称 edt5.Text:= qry1.Fields[0].DisplayName;//readonly edt2.Text:= qry1.Fields[0].Value; edt2.Text:= qry1.Fields[0].FieldName; //ok显示sBH这个字段名 end; end.
书搞进脑袋 创新 创造; 积极