Ver Mensaje Individual
  #1  
Antiguo 18-07-2006
varuhs varuhs is offline
Registrado
 
Registrado: oct 2005
Posts: 7
Reputación: 0
varuhs Va por buen camino
Ejemplo de Ordenamiento StringGrid

Encontre este ejemplo de ordenamiento de un StringGrid y lo he probado y funciona de las mil maravillas.... asi que se los dejo para que lo usen...

Código:
procedure Sortgrid(Grid : TStringGrid; SortCol:integer);
var
   i,j  : Integer;
   temp : TStringList;
begin
Temp:= TStringList.Create;
with Grid
do begin
   for i := FixedRows to RowCount - 2
   do begin
      for j:= i+1 to rowcount-1
      do begin
         if AnsiCompareText(Cells[SortCol, i], Cells[SortCol,j]) > 0
         then begin
              temp.assign(rows[j]);
              rows[j].assign(rows[i]);
              rows[i].assign(temp);
              end;
         end;
      end;
   end;
temp.free;
end;
y en el evento OnMouseUP de la Grilla

Código:
procedure TForm1.StringGrid1MouseUp(Sender: TObject;Button:TMouseButton;Shift: TShiftState; X, Y: Integer);
var
  c : Integer;
begin
with TStringGrid(Sender)
do begin
   if Y <= RowHeights[0]
   then begin
        C:= x div (DefaultColWidth+GridLineWidth);
        SortGrid(TStringGrid(Sender),C);
        end;

   end;
Saludos
Eduardo Valencia López
Santiago - Chile
Responder Con Cita