针对DBGridEh
怎样对没有挂数据库字段的列进行赋值操作?
即(FieldName='')

解决方案 »

  1.   

    有啊
    DBGridEh1.Columns[0].FieldName:='第一列';
      

  2.   

    我不一定是高手,
    如果是想在表格中填值,可以在OnDrawColumnCell事件中处理。
      

  3.   

    我的意思是FieldName的值为空,即不挂数据字段
    那怎样对其中的行进行操作,即进行赋值
      

  4.   

    1、新建工程;
    2、在Form1中放Table1,datasource1,dbgrid1;
    3、设置数据库联接Table1.databasename='DBDEMOS',
    tablename='custoly.db'
    3、在dbgrid中加3个column,前面两个连数据,在OnDrawColumnCell事件写程序。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DB, DBTables, Grids, DBGrids;type
      TForm1 = class(TForm)
        DBGrid1: TDBGrid;
        Table1: TTable;
        DataSource1: TDataSource;
        procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
          DataCol: Integer; Column: TColumn; State: TGridDrawState);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
        if Column.FieldName='' then
        begin
            DBGrid1.Canvas.TextOut(rect.Left,rect.Top,'测试');
        end;
    end;end.