Ayuda con un DBGrid en Delphi

Nancy Paola
28 de Noviembre del 2007
Hola que tal?
Necesito que me ayuden, tengo problemas con el DBGrid.

Con el StringGrid tengo este código que no me causa ningun problema y funciona bien.

if (TxtLaptop1.Text<>'')then
begin

// Buscar la clave de laptop para realizar compra

Self.ClaveLaptop2 := Self.TxtLaptop1.Text;
self.i := 1;
Self.StringGridLaptops.Row := 1;
Bandera := False;

While (Self.i < Self.StringGridLaptops.RowCount) And (Not Bandera) Do
Begin

If Self.StringGridLaptops.Cells[1,i] = Self.ClaveLaptop1 Then
Begin
Bandera := True;
Self.StringGridLaptops.Row := i;
End;

Inc(Self.i);
End;


If Not Bandera Then
ShowMessage('Clave no encontrada')

Else
Begin
Dec(Self.i);
Self.TxtClaveLaptop1.Text := Self.StringGridLaptops.Cells[1,i];
Self.TxtMarcaLaptop1.Text := Self.StringGridLaptops.Cells[2,i];
Self.TxtWindowsLaptop1.Text := Self.StringGridLaptops.Cells[3,i];
Self.TxtCapacidadHDDLaptop1.Text := Self.StringGridLaptops.Cells[4,i];
Self.TxtCapacidadRAMLaptop1.Text := Self.StringGridLaptops.Cells[5,i];
Self.TxtRedInalambrica1.Text := Self.StringGridLaptops.Cells[6,i];
Self.TxtPrecioLaptop1.Text:=Self.StringGridLaptops.Cells[7,i];

End;
self.PrecioLaptop1:=StrToFloat(self.TxtPrecioLaptop1.Text);
end;

__________
El problema es que no se como hacer lo mismo con un DBGrid, puesto que las propiedades son distintas.

Tengo así, pero me da errores.

if (TxtLaptop1.Text<>'')then
begin

// Buscar la clave de laptop para realizar compra

Self.ClaveLaptop1 := Self.TxtLaptop1.Text;
self.i := 1;

Self.DBGridLaptop.SelectedRows := 1;
//.Row
Bandera := False;

While (Self.i < Self.DBGridLaptop.FieldCount) And (Not Bandera) Do
//.RowCount
Begin

If Self.DBGridLaptop.DefaultDrawColumnCell[1,i] = Self.ClaveLaptop1 Then
//.cells
Begin
Bandera := True;
Self.DBGridLaptop.Fields := i;
End;

Inc(Self.i);
End;


If Not Bandera Then
ShowMessage('Clave no encontrada')

Else
Begin
Dec(Self.i); //.cells
Self.TxtClaveLaptop1.Text := Self.DBGridLaptop.DefaultDrawColumnCell[1,i];
Self.TxtMarcaLaptop1.Text := Self.DBGridLaptops.DefaultDrawColumnCell[2,i];
Self.TxtWindowsLaptop1.Text := Self.DBGridLaptops.DefaultDrawColumnCell[3,i];
Self.TxtCapacidadHDDLaptop1.Text := Self.DBGridLaptops.DefaultDrawColumnCell[4,i];
Self.TxtCapacidadRAMLaptop1.Text := Self.DBGridLaptops.DefaultDrawColumnCell[5,i];
Self.TxtRedInalambrica1.Text := Self.DBGridLaptops.DefaultDrawColumnCell[6,i];
Self.TxtPrecioLaptop1.Text:=Self.DBGridLaptops.DefaultDrawColumnCell[7,i];

End;
self.PrecioLaptop1:=StrToFloat(self.TxtPrecioLaptop1.Text);
end;

_______
No se que pueda ser, ya no se donde tengo el error.

Ayudenme porfavor.

¿Síiiiiiii...?

Mil gracias de antemano.