if FieldComboBox.Items.Count<>0 then FieldComboBox.Items.Clear; FEyeDataSet:=ADataSet; for I:=0 to FEyeDataSet.FieldCount-1 do FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I]; with FEyeDataSet do begin for I:=0 to FEyeDataSet.FieldCount -1 do begin if not Fields[I].Visible then Continue; if not CanFilter(Fields[I]) then Continue; FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]); end; end; FFilterStr:='';
if FieldComboBox.Items.Count<>0 then FieldComboBox.Items.Clear; FEyeDataSet:=ADataSet; for I:=0 to FEyeDataSet.FieldCount-1 do FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I]; with FEyeDataSet do begin for I:=0 to FEyeDataSet.FieldCount -1 do begin if not Fields[I].Visible then Continue; if not CanFilter(Fields[I]) then Continue; FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]); end; end; FFilterStr:='';
if FieldComboBox.Items.Count<>0 then FieldComboBox.Items.Clear; FEyeDataSet:=ADataSet; for I:=0 to FEyeDataSet.FieldCount-1 do FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I]; with FEyeDataSet do begin for I:=0 to FEyeDataSet.FieldCount -1 do begin if not Fields[I].Visible then Continue; if not CanFilter(Fields[I]) then Continue; FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]); end; end; FFilterStr:='';
if ADOQuery6.Active=true then ADOQuery6.Close; ADOQuery6.SQL.clear; ADOQuery6.sql.add('select * from tab_kmmc order by c1'); adoquery6.open; ComboBox1.Items.Clear; if ADOQuery6.RecordCount>0 then begin for i:=1 to ADOQuery6.RecordCount do begin ADOQuery6.RecNo:=i; ComboBox1.Items.Append(adoquery6.findfield('c1').asstring); end; end
procedure TQueryBilForm.SetEyeDataSet(ADataSet: TClientDataSet); var I:Integer; begin if FieldComboBox.Items.Count<>0 then FieldComboBox.Items.Clear; FEyeDataSet:=ADataSet; for I:=0 to FEyeDataSet.FieldCount-1 do FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I]; with FEyeDataSet do begin for I:=0 to FEyeDataSet.FieldCount -1 do begin if not Fields[I].Visible then Continue; if not CanFilter(Fields[I]) then Continue; FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]); end; end; FFilterStr:=''; end;
读进去: FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);要用的时候: var CurField:TField; CurField:=TField(FieldComboBox.Items.Objects[FieldComboBox.ItemIndex]);这下知道了吧!
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
我理解的是你想:
将某个字段的值读取出来作为combobox的item吗?
这个肯定很好实现啊 稍微懂点vcl与数据库都可以实现
ADOQuery6.SQL.clear;
ADOQuery6.sql.add('select * from tab_kmmc order by c1');
adoquery6.open;
ComboBox1.Items.Clear;
if ADOQuery6.RecordCount>0 then
begin
for i:=1 to ADOQuery6.RecordCount do
begin
ADOQuery6.RecNo:=i;
ComboBox1.Items.Append(adoquery6.findfield('c1').asstring);
end;
end
var
I:Integer;
begin
if FieldComboBox.Items.Count<>0 then
FieldComboBox.Items.Clear;
FEyeDataSet:=ADataSet;
for I:=0 to FEyeDataSet.FieldCount-1 do
FEyeDataSet.Fields[I].DisplayLabel:=FieldList[I];
with FEyeDataSet do
begin
for I:=0 to FEyeDataSet.FieldCount -1 do
begin
if not Fields[I].Visible then Continue;
if not CanFilter(Fields[I]) then Continue;
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);
end;
end;
FFilterStr:='';
end;
是关键!
FieldComboBox.Items.AddObject(Fields[I].DisplayLabel,Fields[I]);要用的时候:
var
CurField:TField;
CurField:=TField(FieldComboBox.Items.Objects[FieldComboBox.ItemIndex]);这下知道了吧!
DBLOOKUPCOMBOBOX.keyvalue=query1.fieldbyname('field').asstring