Ver Mensaje Individual
  #1  
Antiguo 29-06-2011
Ignacio Gentile Ignacio Gentile is offline
Miembro
NULL
 
Registrado: may 2011
Posts: 15
Reputación: 0
Ignacio Gentile Va por buen camino
Problema Al Obtener Elementos En Combobox

Buenas! Mi problema es que agrego elementos a un combobox y se agregan bien, los muestra bien pero al momento de seleccionar uno siempre me selecciona el mismo..Evaluando el ItemIndex me doy cuenta de que obtiene bien el index del elemento seleccionado pero no me devuelve el objeto incorrecto y no le puedo encontrar el problema de porque pasa eso..Revisando el código no encuentro el error. Dejo el segmento de código,si alguno me puede ayudar seria bueno

Código Delphi [-]
type
  TEmpresa = class (TObject)
    id:integer;
    descripcion:string;
  end;

procedure TfrmElegirEmpresa.ListaEmpresa;
var nuevoItem:TEmpresa;
    j:integer;
begin
      for j:=0 to ZQuery1.RecordCount-1 do
          begin
             if (DBGrid1.Fields[0].Value = nuevoItem.id) then
              begin
                  cmbEmpresa.Items.AddObject(nuevoItem.Descripcion, nuevoItem);
              end;
             ZQuery1.Next
          end;
end;

procedure TfrmElegirEmpresa.cmbEmpresaChange(Sender: TObject);
var indice:integer;
    item:TEmpresa;
begin
   indice:=cmbEmpresa.ItemIndex;
   item:= TEmpresa(cmbEmpresa.Items.Objects[indice]);
   edtEmpresa.Text := IntToStr(item.id) ;

   cmbSucursal.Items.Clear;
   ListaSucursal(item.id);
end;
Responder Con Cita