DBGrid中下拉列表的应用PickList\keylist with DBGridEh1 do begin SelectedField.FieldName :='Field1'; I := SelectedIndex; with AdoQuery1 do begin close; sql.clear ; sql.add(' select FieldMc from DictTable1 '); open; first; Columns[i].KeyList.Clear; Columns[i].picklist.Clear; while not eof do begin Columns[I].KeyList.Add(fieldbyname('FieldMc').AsString); Columns[I].PickList.Add(fieldbyname('FieldMc').AsString); next; end; end; Columns[i].AutoDropDown := true; SelectedField := Columns[i].Field; end;
with DBGridEh1 do
begin
SelectedField.FieldName :='Field1';
I := SelectedIndex;
with AdoQuery1 do
begin
close;
sql.clear ;
sql.add(' select FieldMc from DictTable1 ');
open;
first;
Columns[i].KeyList.Clear;
Columns[i].picklist.Clear;
while not eof do
begin
Columns[I].KeyList.Add(fieldbyname('FieldMc').AsString);
Columns[I].PickList.Add(fieldbyname('FieldMc').AsString);
next;
end;
end;
Columns[i].AutoDropDown := true;
SelectedField := Columns[i].Field;
end;