假如用WWTable控件联结到一个表,该表的字段名为(field1,field2,field3)
在wwTable中将各字段的DisplayLabel设置为(编号,姓名,性别)请教如何用一个
Function  GetFieldName(物理字段名): 逻辑字段名

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons, DB, ADODB, Grids, DBGrids;type
      TForm1 = class(TForm)
        DataSource1: TDataSource;
        ADOTable1: TADOTable;
        BitBtn1: TBitBtn;
        DBGrid1: TDBGrid;
        procedure BitBtn1Click(Sender: TObject);
      private
        fUNCTION GETFNAME(S:STRING):STRING;
         fUNCTION GETFNAME2(S:STRING):STRING;
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    function TForm1.GETFNAME(S: STRING): STRING;
    var i:integer;
    begin
      for i :=0  to ADOTable1.FieldCount-1 do begin
        if ADOTable1.Fields[i].DisplayLabel=S then
          Result:=ADOTable1.Fields[i].FieldName;
      end;  //For
    end;function TForm1.GETFNAME2(S: STRING): STRING;
    begin
      Result:=ADOTable1.Fieldbyname(s).DisplayName;
    end;
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      with ADOTable1 do begin
        Fields[0].DisplayLabel:='A';
        Fields[1].displayLabel:='B';
        Fields[2].DisplayLabel:='C';
        ShowMessage(GETFNAME('A'));
        ShowMessage(GETFNAME2('field1'));
      end;   //withend;end.