Ver Mensaje Individual
  #9  
Antiguo 05-08-2010
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Reputación: 20
FGarcia Va por buen camino
Bueno a lo que habia llegado hasta el momento es:

Código Delphi [-]
unit UfrmCaptura;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, ComCtrls, TeEngine, ExtCtrls, TeeProcs, Chart;

type
  TfrmCaptura = class(TForm)
    StringGrid1: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
  private
    { Private declarations }
    procedure InicializaStringGrid;
  public
    { Public declarations }
  end;

var
  frmCaptura: TfrmCaptura;

implementation

{$R *.dfm}

procedure TfrmCaptura.FormCreate(Sender: TObject);
begin
  InicializaStringGrid;
end;

procedure TfrmCaptura.FormShow(Sender: TObject);
begin
  //Unos datos solo para visualizar
  Stringgrid1.cells[1,2] := '12.000';
  StringGrid1.Cells[2,2]:= '50,000.00'; 
end;

//Este procedimiento llena las filas de la rejilla con los encabezados
procedure TfrmCaptura.InicializaStringGrid ;
var
  r,a,p: integer;
begin

   with StringGrid1 do
    begin
      Top := 8;
      Left := 8;
      Height := 279;
      Width := 246;

      ColCount := 3;
      RowCount:= 29;
      fixedRows := 2;
      fixedCols := 1;

      Cells[0,1] := 'Hora';
      ColWidths[0] := 80;

      Cells[1,1] := 'Operaciones';
      ColWidths[1] := 70;

      Cells[2,1] := 'Acumulado';
      ColWidths[2] := 70;
    end;
  
  //Aqui lleno los renglones de los horarios
  for r := 0 to 26 do  
    begin
      case r  of
        0 : begin
              a := 6;
              p := a + 1;
              StringGrid1.Cells[0,(r + StringGrid1.FixedRows )] := IntToStr(a)+ ':00' +
                                                      ' - ' +
                                                      IntToStr(p) + ':00';
            end;
        8,17,26 : StringGrid1.Cells[0,(r + StringGrid1.FixedRows )] := 'Resumen';
       20 : begin
              a := 0;
              p := a + 1;
              StringGrid1.Cells[0,(r + StringGrid1.FixedRows )] := IntToStr(a)+ ':00' +
                                                      ' - ' +
                                                      IntToStr(p) + ':00';
            end ;
       else
          begin
            a := p;
            p := p + 1;
            StringGrid1.Cells[0,(r + StringGrid1.FixedRows )] := IntToStr(a)+ ':00' +
                                                      ' - ' +
                                                      IntToStr(p) + ':00';
          end;
      end;
    end;


end;

//Este procedimiento alinea a la derecha el contenido de las celdas. Tambien da
//color a las columnas en el StringGrid 1
procedure TfrmCaptura.StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var sCad: String;
    i: Integer;
begin
  If (ACol=1) Or (ACol=2) Then
    if ARow > 1 then //No quiero alinear la línea de títulos
      If StringGrid1.Cells[ACol,ARow] <> '' Then
        Begin
          sCad := StringGrid1.Cells[ACol,ARow];
          With StringGrid1 Do
            with Canvas,Rect do
              Begin
                Canvas.Brush.Style := bsSolid;
                case ACol of
                  1: Canvas.Brush.Color := clYellow;
                  2: Canvas.Brush.Color := clRed;
                end;
                i:=Right-TextWidth(sCad+' ');
                Canvas.FillRect(Rect);
                Canvas.TextOut(i,Top+2,sCad);
              End;
        End;
end;

end.

No pongo el archivo pues uso d2010 y parece ser que no es posible abrirlo con versiones anteriores. El formulario es un simple form con un StringGrid. El codigo de la Unit le da tamaño y posicion.

Editando: Caral como puedes ver para la columna horario estoy usando la propiedad FixedRows, tu ejemplo me dio otras ideas.

Contraveneno la verdad no me caen muy bien las jedi, ya d2010 se tarda años en arrancar y todavia cargar la JVCL..... De todos modos no hecho en saco roto tu propuesta.
Imágenes Adjuntas
Tipo de Archivo: jpg Rejilla.jpg (19,0 KB, 57 visitas)
__________________
ESTO ES UN FORO ... NO UN MÓVIL
¿Por qué no escribir de una manera comprensible para que los humanos lo podamos entender?

Última edición por FGarcia fecha: 05-08-2010 a las 02:37:22.
Responder Con Cita