Ver Mensaje Individual
  #15  
Antiguo 05-08-2010
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - Espańa
Posts: 18.286
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Lo bueno del TStringGrid es que el pintado es relatívamente sencillo; POr ejemplo, para el tema de los títulos con algo de código en el evento OnDrawCell puedes conseguir algo así:



Código Delphi [-]
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  sCad: String;
  i: Integer;

  procedure _PaintTitle1(ACol:integer);
  var
    ATitle:string;
  begin

    if (ACol=0) or (ACol=1) or (ACol=2) then begin
      ATitle := 'Primer turno';
    end
    else if (ACol=3) or (ACol=4) or (ACol=5) then begin
      ATitle := 'Segundo turno';
    end
    else if (ACol=6) or (ACol=7) or (ACol=8) then begin
      ATitle := 'Tercer turno';
    end;

    InflateRect(Rect, -1, -2);

    StringGrid1.Canvas.Pen.Color := clBlack;
    StringGrid1.Canvas.Brush.Style := bsSolid;
    StringGrid1.Canvas.Brush.Color := $00E6E6E6;
    StringGrid1.Canvas.Rectangle(Rect);
    Application.ProcessMessages;
    StringGrid1.Canvas.TextOut(Rect.Left + 5,Rect.Top + 3, ATitle);
    Application.ProcessMessages;
  end;

  procedure _PaintTitle2(ACol:integer);
  var
    ATitle:string;
  begin

    if (ACol=0) or (ACol=3) or (ACol=6) then begin
      ATitle := 'Hora';
    end
    else if (ACol=1) or (ACol=4) or (ACol=7) then begin
      ATitle := 'Operaciones';
    end
    else if (ACol=2) or (ACol=5) or (ACol=8) then begin
      ATitle := 'Acumulado';
    end;

    InflateRect(Rect, -1, -2);

    StringGrid1.Canvas.Pen.Color := clBlack;
    StringGrid1.Canvas.Brush.Style := bsSolid;
    StringGrid1.Canvas.Brush.Color := $00E6E6E6;
    StringGrid1.Canvas.Rectangle(Rect);
    Application.ProcessMessages;
    StringGrid1.Canvas.TextOut(Rect.Left + 5,Rect.Top + 3, ATitle);
    Application.ProcessMessages;
  end;

begin

  StringGrid1.Options := StringGrid1.Options - [goFixedVertLine];

  if (ARow = 0) then begin
    if (ACol=0) or (ACol=3) or (ACol=6) then begin
      Rect.Right := Rect.Right + StringGrid1.ColWidths[ACol+1] + StringGrid1.ColWidths[ACol+2];
      _PaintTitle1(ACol);
    end;
    if (ACol=1) or (ACol=4) or (ACol=7) then begin
      Rect.Left := Rect.Left - StringGrid1.ColWidths[ACol-1];
      Rect.Right := Rect.Right - StringGrid1.ColWidths[ACol+1];
      Rect.Left := Rect.Left-1;
      _PaintTitle1(ACol);
    end;
    if (ACol=2) or (ACol=5) or (ACol=8) then begin
      Rect.Left := Rect.Left - StringGrid1.ColWidths[ACol-1] - StringGrid1.ColWidths[ACol-2];
      Rect.Left := Rect.Left-2;
      _PaintTitle1(ACol);
    end;
  end;

  if (ARow = 1) then begin
    _PaintTitle2(ACol);
  end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita