可以呀,楼主,你可以这样:
var
id1:string;
with ADOQuery do
begin
Close;
SQL.Clear;
SQL.Text:='select ID from table1 where 姓名='''+dbgrid1.Fields[1].AsString+'''' //把你从Picklist下拉列表选取的姓名对应的ID取出来
Open;
id1:=FieldByName('ID').Asstring; //用这一变量存入你提取的ID号
procedure TForm1.ADOTable1idGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
case Sender.AsInteger of
0: Text := '男';
1: Text := '女';
2: Text := '两性人';
else
Text := Sender.AsString;
end;
end;
当然可以实现了:
参考一下://动态创建
var
a:TStringList;
begin
a:=TStringList.Create;
with ADOQuery do
begin
Close;
SQL.Clear;
SQL.Text:='select * from Table1';
Open;
while not Eof do
begin
a.Add(FieldValues['姓名']);
Next;
end;
end;
dbgrid1.Columns[1].PickList:=a;
a.Free;