Ver Mensaje Individual
  #3  
Antiguo 21-11-2009
Avatar de José Luis Garcí
[José Luis Garcí] José Luis Garcí is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Las Palmas de G.C.
Posts: 1.372
Reputación: 25
José Luis Garcí Va camino a la fama
Gracias por tu ayuda Jhonny, respondiendo a la pregunta a qui va las partes del código

Variables generales
Código Delphi [-]
var
  Form1: TForm1;
  footer:tstatusbar;
  fin, Colfin,colini: integer;

El OnCreate del Form
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
var footer:tstatusbar;
  i:integer;
begin
     footer:=TStatusBar.Create(self);
   //  footer.SetParentComponent(DBGrid1);
     footer.Parent:=DBGrid1;
     footer.Top:=DBGrid1.Height;
     footer.Left:=DBGrid1.Left;
     footer.Width:=dbgrid1.Width;
     footer.Panels.Add;
     footer.Panels.Items[0].Width:=11;
     for I := 1 to DBGrid1.Columns.Count-1  do
     begin
        footer.Panels.Add;
        footer.Panels.Items[i].Width:=DBGrid1.Columns.Items[i-1].Width+2;
     end;
     fin:=0;
     colfin:=0;
end;

Y El DrawColumnCell
Código Delphi [-]
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
  var i:integer;
begin
    if fin=0 then
    begin
       fin:=1;
       colini:=Column.ID;
    end;
    if column.id>Colfin then colfin:=Column.ID;

     if (DBGrid1.DataSource.DataSet.RecNo=DBGrid1.DataSource.DataSet.RecordCount)
        and
        (Column.ID=colfin) then//Saber si estamos en la última fila visible
     begin
//             
             for I := 0 to footer.Panels.Count -1  do  //AQUI DA EL FALLO
              begin
                  if (i>=(colini))and(i<=(Colfin)) then
                  begin
                    footer.Panels.Items[i].Width:=DBGrid1.Columns.Items[i].Width;
                    footer.Panels.Items[i].Text:=IntToStr(Column.ID);

                  end else Footer.Panels.Items[i].Width:=0;

              end;
              
              fin:=0;
     end;
end;
__________________
Un saludo desde Canarias, "El abuelo Cebolleta"
Responder Con Cita