Ver Mensaje Individual
  #3  
Antiguo 04-12-2006
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Te pongo un ejemplo usando un DBGrid normal. Este es el evento OnDrawColumnCell del DBGrid:

Código Delphi [-]
procedure TForm1.DBGrid1DrawColumnCell(
  Sender: TObject; const Rect: TRect; DataCol: Integer;
  Column: TColumn; State: TGridDrawState);
var
  Bmp: TBitmap;
  L, T: Integer;

begin
  // Si es la columna donde deseas poner la imagen...
  if DataCol = 4 then
  begin
    // Seleccionas la imagen a usar según el valor del campo
    if Table1.FieldByName('campo').AsBoolean then
      Bmp := BitmapSi
    else
      Bmp := BitmapNo;

    // Calculas las coordenadas para que la imagen quede centrada en la celda
    L := Rect.Left + (Rect.Right - Rect.Left - Bmp.Width) div 2;
    T := Rect.Top + (Rect.Bottom - Rect.Top - Bmp.Height) div 2;

    // Dibujas la imagen
    DBGrid1.Canvas.Draw(L, T, Bmp);
  end
  else
    DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

Aquí, BitmapSi y BitmapNo serían dos TBitmap creados al inicio con las imágenes que quieras:

Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
begin
  BitmapSi := TBitmap.Create;
  BitmapSi.LoadFromFile('SI.bmp');

  BitmapNo := TBitmap.Create;
  BitmapNo.LoadFromFile('NO.bmp');
end;

y destruidos al final

Código Delphi [-]
procedure TForm1.FormDestroy(Sender: TObject);
begin
  BitmapSi.Free;
  BitmapNo.Free;
end;

// Saludos
Responder Con Cita