各位看看,绑定的问题
scsun 2003-09-12 10:02:15 开发环境(Delphi6/ADO/TdxDBGrid/TdxDBEdit)
=========================================
我的目的是把一个某表单中的TdxDBTree的Datasource.Dataset 作为另一个编辑表单的各控件的 DataSource.Dataset.
然后把这个RecordSet的字段绑字到 各个TdxDBEdit.DataField.以便对记录操作!
但是打开编辑表单后,编辑表单的各编辑控件对绑定的数据不敏感,数据的操作不能在这些控件反应出来. 这些控件的DataField与DataSource都已正确设置.
绑定数据源代码
=========================================
procedure TfrmTBASESimpleEditor.loadData;
begin
AdoSetMaster := TADODataSet(oMainTree.DataSource.Dataset);
end;
function TfrmTBASESimpleEditor.setControlState:boolean;
var
i ,j: integer;
begin
result :=true;
j :=1;
Caption :=sCaption;
LbTitle.Caption := sCaption+'编辑';
if ADOSetMaster.Active then
begin
for i:=0 to oMainTree.ColumnCount-1 do
begin
if not oMainTree.Columns[i].Visible then continue;
(FindComponent('Label'+intToStr(j)) as TLabel).Caption :=oMainTree.Columns[i].Caption + ':';
(FindComponent('dxEdit'+intToStr(j)) as TdxDBEdit).DataField :=oMainTree.Columns[i].FieldName;
(FindComponent('dxEdit'+intToStr(j)) as TdxDBEdit).Enabled :=true;
j := j+1;
end;
while j<=5 do
begin
(FindComponent('Label'+intToStr(j)) as TLabel).Visible:=false;
(FindComponent('dxEdit'+intToStr(j)) as TdxDBEdit).Visible:=false;
j :=j+1;
end;
bRet :=true;
case vEditorAction of
eaADD:;
eaEdit: bsOKNew.Visible :=false;
eaView:
begin
bsSkinPanel1.Enabled :=false;
bsOK.Visible :=false;
bsOKNew.Visible :=false;
end;
end;
end
else
begin
bRet :=false;
end;
end;