F fx Unregistered / Unconfirmed GUEST, unregistred user! 1999-04-06 #5 在设计阶段,New一个普通型字段, 程序运行时根据条件,Close Dataset,把字段的Calculated设为True,Open DataSet, 这样不行吗?
C CJ Unregistered / Unconfirmed GUEST, unregistred user! 1999-04-08 #7 sorry 我试了一下,好象 CREATE 不出来:(( 自在己ONCACULATEFIELD中写代码,把计算结果写到某变量,然后用吧
S SeaSky Unregistered / Unconfirmed GUEST, unregistred user! 1999-07-21 #8 试了一下, OK了. procedure TForm1.Button1Click(Sender: TObject); Var HHH : TStringField ; begin HHH:=TStringField.Create(Query1); HHH.FieldName := 'Test1' ; HHH.Size := 2 ; HHH.Calculated := true ; HHH.dataset := Query1 ; QUery1.open ; end; procedure TForm1.Query1CalcFields(DataSet: TDataSet); begin with Dataset do begin If fieldbyname('Weight').asinteger > 10 then FieldByName('Test1').asstring := '重' else FieldByName('Test1').asstring := '轻'; end ; end;
试了一下, OK了. procedure TForm1.Button1Click(Sender: TObject); Var HHH : TStringField ; begin HHH:=TStringField.Create(Query1); HHH.FieldName := 'Test1' ; HHH.Size := 2 ; HHH.Calculated := true ; HHH.dataset := Query1 ; QUery1.open ; end; procedure TForm1.Query1CalcFields(DataSet: TDataSet); begin with Dataset do begin If fieldbyname('Weight').asinteger > 10 then FieldByName('Test1').asstring := '重' else FieldByName('Test1').asstring := '轻'; end ; end;
S SeaSky Unregistered / Unconfirmed GUEST, unregistred user! 1999-09-03 #10 XK : 快点结束这个问题吧, 我给我加不上分. 其他人都没有做出来. (
L Liu JZX Unregistered / Unconfirmed GUEST, unregistred user! 1999-09-03 #11 将所需要的表的字段添加到Table控件永久字段中,写如下程式 procedure TForm1.Button1Click(Sender: TObject); var tt:TIntegerField; begin tt:=TIntegerField.Create(self); tt.FieldName := 'Test1' ; tt.FieldKind:=fkCalculated; tt.DataSet:=table1; table1.active:=true; end; procedure TForm1.Table1CalcFields(DataSet: TDataSet); begin table1.fieldbyname('test1').asinteger:=random(555); end; procedure TForm1.FormCreate(Sender: TObject); begin randomize; end;
将所需要的表的字段添加到Table控件永久字段中,写如下程式 procedure TForm1.Button1Click(Sender: TObject); var tt:TIntegerField; begin tt:=TIntegerField.Create(self); tt.FieldName := 'Test1' ; tt.FieldKind:=fkCalculated; tt.DataSet:=table1; table1.active:=true; end; procedure TForm1.Table1CalcFields(DataSet: TDataSet); begin table1.fieldbyname('test1').asinteger:=random(555); end; procedure TForm1.FormCreate(Sender: TObject); begin randomize; end;
L Liu JZX Unregistered / Unconfirmed GUEST, unregistred user! 1999-09-03 #12 将所需要的表的字段添加到Table控件永久字段中,写如下程式 procedure TForm1.Button1Click(Sender: TObject); var tt:TIntegerField; begin tt:=TIntegerField.Create(self); tt.FieldName := 'Test1' ; tt.FieldKind:=fkCalculated; tt.DataSet:=table1; table1.active:=true; end; procedure TForm1.Table1CalcFields(DataSet: TDataSet); begin table1.fieldbyname('test1').asinteger:=random(555); end; procedure TForm1.FormCreate(Sender: TObject); begin table1.close; randomize; end;
将所需要的表的字段添加到Table控件永久字段中,写如下程式 procedure TForm1.Button1Click(Sender: TObject); var tt:TIntegerField; begin tt:=TIntegerField.Create(self); tt.FieldName := 'Test1' ; tt.FieldKind:=fkCalculated; tt.DataSet:=table1; table1.active:=true; end; procedure TForm1.Table1CalcFields(DataSet: TDataSet); begin table1.fieldbyname('test1').asinteger:=random(555); end; procedure TForm1.FormCreate(Sender: TObject); begin table1.close; randomize; end;