Ver Mensaje Individual
  #4  
Antiguo 17-05-2007
Avatar de fjcg02
[fjcg02] fjcg02 is offline
Miembro Premium
 
Registrado: dic 2003
Ubicación: Zamudio
Posts: 1.410
Reputación: 22
fjcg02 Va camino a la fama
Con Access, cargadas las imagenes en campos objeto OLE ( o eso creo )

Código Delphi [-]
procedure TFormSubclases.DBGrid1DrawDataCell(Sender: TObject;
  const Rect: TRect; Field: TField; State: TGridDrawState);
var icono: TBitmap;
begin
if Field.Name = 'TablaSubclasesdibujo' then
begin
  try
   icono:= Tbitmap.Create;
   icono.Assign(TBlobField(Field));
   (Sender as TDBGrid).Canvas.FillRect(Rect);
   (Sender as TDBGrid).Canvas.Draw(Rect.left+3,Rect.Top+1, icono);
  finally
    icono.free;
  end;
end
else
    (Sender as TDBGrid).DefaultDrawDataCell(Rect, Field, State);
end;

PAra cargar las imagenes a la BBDD, pongo un DBImage asociado al campo y un boton, con este código

Código Delphi [-]
procedure TFormSubclases.BitBtn1Click(Sender: TObject);
begin
  with TOpendialog.Create(nil) do
  try
    Filter:= 'Archivos de imagen|*.bmp;*.ico;*.jpg';
    if Execute then
    begin
      TablaSubclases.Edit;
      DBImage1.Picture.LoadFromFile(Filename);
    end;
  finally
    Free;
  end;
end;
y ya pinto una imagen en el grid. PAra lo que yo necesito, suficiente. Queda pulir los altos de las filas por si utilizas imagenes de diferentes tamaños, ... pero con eso nunca me he metido.

Suerte y saludos
__________________
Cuando los grillos cantan, es que es de noche - viejo proverbio chino -
Responder Con Cita