Buscar

Inserir uma linha no meio do TStringGrid

Código

// by André Feltrin Baldessar
//
// A função abaixo insere uma linha num TStringGrid APÓS uma linha escolhida.
//
// Uso: GridInsertRow(StrGrid,Linha)
// Onde: StrGrid = nome do componente TStringGrid no form.
// Onde: Linha = linha anterior
//
// Exemplo: inserir uma linha após o cabeçalho do Grid, empurrando todos as outras para baixo: GridInsertRow(meustrgrid,1);


function GridInsertRow(StrGrid: TStringGrid; Linha:integer):integer;
Var Rown,Coln: Integer;
begin
  strgrid.RowCount:=strgrid.RowCount+1;
  if Linha<1 then Linha:=1
  else if Linha>strgrid.RowCount-1 then Linha:=strgrid.RowCount-1;
  if strgrid.RowCount-1 <> Linha then
  for Rown:=strgrid.RowCount-1 downto Linha do
      for Coln:=0 to strgrid.ColCount-1 do
         strgrid.Cells[Coln,Rown]:=strgrid.Cells[Coln,Rown-1];
  result:=Linha;
end;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Forms
Adicionada dia: 19/06/10
Por: André F
Visualizada: 5334 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009