Zona HTML Zona Java Zona PHP Zona ASP Zona Bases de datos
Inicio > Foros > Delphi / Kylix / C++ Builder > Ayuda con un DBGrid en Delphi
-Foros de debate

Delphi / Kylix / C++ Builder
Lista de foros | Lista de mensajes de este foro

Privacidad: Recuerde que la información escrita en los foros de programación es 100% pública y que su ip será registrada asociada a su mensaje. Si encuentra un mensaje fuera de lugar, por favor, notifiquelo para su revisión y eliminación.

Ayuda con un DBGrid en Delphi
Enviado por Nancy Paola el día 28 de noviembre de 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.

 

Tienda
Patrocinados
 

Copyright © 1999-2006 Programación en castellano. Todos los derechos reservados.
Formulario de Contacto - Datos legales - Publicidad

Hospedaje web y servidores dedicados linux por Ferca Network