Kod: Tümünü seç
function combo_doldur(TableName, ValueField, DisplayField, Value, WhereStr: string): TComboBox;
var
sqlstr: string;
strDisplay: string;
strValue: integer;
begin
Result := TComboBox.CreateParented(Application.Handle);
sqlstr := 'SELECT ' + DisplayField + ', ' + ValueField + ' FROM ' + TableName + ' ' + WhereStr;
with DM do
begin
QTemp.SQL.Clear;
QTemp.SQL.Add(sqlstr);
Qtemp.Open;
while not QTemp.Eof do
begin
strDisplay := QTemp.Fields[0].AsString;
strValue := QTemp.Fields[1].AsInteger;
Result.Items.AddObject(strDisplay, TObject(strValue));
QTemp.Next;
if StrToInt(Value) = strValue then Result.ItemIndex := Result.Items.Count-1;
end;
end;
end;