Ver Mensaje Individual
  #2  
Antiguo 13-08-2008
Avatar de Nomad
Nomad Nomad is offline
Miembro
 
Registrado: abr 2007
Ubicación: Sarchi,Costa Rica
Posts: 107
Reputación: 18
Nomad Va por buen camino
Vean lo que se me ocurrió, aunque aún no funciona, creo que estoy bastante cerca, asi que cualquier ayuda o sugerencia es bien recibida.

Lo que hice fue que dentro del procedimiento OnDrawCell ingrese una variable boolean y puse una condicion, en la cual, si la variable es true, entonces debe cambiar el estilo por negrita.

Busque la variable PINTAR en el codigo:
Código Delphi [-]
procedure TFDistri.GrDetalleDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  sTexto: String;           // Texto que va a imprimir en la celda actual
  Alineacion: TAlignment;   // Alineación que le vamos a dar al texto
  iAnchoTexto: Integer;     // Ancho del texto a imprimir en pixels
begin
with GrDetalle.Canvas do
  begin
    // Lo primero es coger la fuente por defecto que le hemos asignado al componente
    Font.Name := GrDetalle.Font.Name;
    Font.Size := GrDetalle.Font.Size;
    if ARow = 0 then
      Alineacion := taCenter
    else
      // Si es la columna del importe pendiente alineamos el texto a la derecha
      if ACol = 4 then
        Alineacion := taRightJustify
      else
        Alineacion := taLeftJustify;

    // ¿Es una celda fija de sólo lectura?
    if gdFixed in State then
    begin
      Brush.Color := clNavy;      // le ponemos azul de fondo
      Font.Color := clWhite;      // fuente blanca
      Font.Style := [fsBold];     // y negrita
    end
    else
    if  pintar then
    begin
       Font.Style := [fsBold];     // negrita
    end;
    sTexto := GrDetalle.Cells[ACol,ARow];
    FillRect( Rect );
    iAnchoTexto := TextWidth( sTexto );
    case Alineacion of
      taLeftJustify: TextOut( Rect.Left + 5, Rect.Top + 2, sTexto );
      taCenter: TextOut( Rect.Left + ( ( Rect.Right - Rect.Left ) - iAnchoTexto ) div 2, Rect.Top + 2, sTexto );
      taRightJustify: TextOut( Rect.Right - iAnchoTexto - 2, Rect.Top + 2, sTexto );
    end;
  end;
end;

Luego lo que hice donde mando escribir el valor en la celda, puse la variable variable pintar = true, escribo el valor y luego pongo pintar = false.

Código Delphi [-]
pintar := true;
GrDetalle.Cells[col+2,memfila] := IntToStr(Suma);
pintar := false;

Pero el problema es que algo no estoy haciendo bien, porque siempre llega la variable PINTAR en false. y si quito la parte donde dice pintar = false, me pone todos las celdas en negrita.

Gracias por la ayuda...
__________________
Quisiera cambiar el mundo, pero no me dan el código fuente.
Responder Con Cita