GARANTIR DESCONTO

Fórum Erro num StringGrid #374116

26/08/2009

0

Esse é o erro no meu StringGrid

Fixed row count must be less than row count;


Abaixo mu código

var i, j : integer;
    Cresc : ^TCrescimento;
begin
  if IndexIndice = 0 then
    if pgcCapa.ActivePageIndex = 1 then
      if listview.Items.Count > 0 then
        btnTransformadores.Enabled := true
      else
        btnTransformadores.Enabled := false;
  with StringGrid do
    begin
    if (ListView.Selected = nil) or (ListView.Selected.Data = nil) then
    begin
      RowCount := 1;
      ColCount := 1;
      Exit;
    end;

    Cresc := ListView.Selected.Data;
    ColCount  := Trunc(QtdAnos)+1;
    FixedCols := 1;

    ColWidths[0] := 90;

    for i := 1 to ColCount-1 do
      Cells[i,0] := ´Ano ´+FloatToStr(i);

    RowCount  := Length(Cresc^)+1;
    FixedRows := 1;

    for i := 0 to length(Cresc^)-1 do
    begin
      SetLength(Cresc^[i].Anos,QtdAnos);
      Cells[0,i+1] := Cresc^[i].NomeClasse;
      for j := 0 to Length(Cresc^[i].Anos)-1 do
      begin
        if Cresc^[i].Anos[J].ValorPorc = 0 then
          Cresc^[i].Anos[J].ValorPorc := 0;
        Cells[j+1,i+1] := FloatToStr(Cresc^[i].Anos[J].ValorPorc);
      end;
    end;
  end;
end;



Paulo

Paulo

Responder

Posts

26/08/2009

Osocram

Olha.. eu odeio StringGrid.
mas pela logica o seu prob deve estar aqui
    ColCount  := Trunc(QtdAnos)+1;
    FixedCols := 1; 

acho que o Trunc(QtdAnos) esta vindo com 0

A msg de erro fala que
Fixed row count must be less than row count;

O numero de linha fixa deve ser menor que o numero de linha;



Responder

Gostei + 0

26/08/2009

Paulo

Eu odeio tambem, mas já está assim. O erro se dá nesta linha:

    RowCount  := Length(Cresc^)+1; 
    FixedRows := 1;



Responder

Gostei + 0

26/08/2009

Osocram

Opa quase acertei então..
Mas agora tem q avaliar a logica ae...
o RowCount não pode ser igual ao FixedRows

poderia fazer isso

RowCount := Length(Cresc^)+1;
if rowCount <= 1 then
FixedRows := 0
else
FixedRows := 1

Eu odeio tambem, mas já está assim. O erro se dá nesta linha:
    RowCount  := Length(Cresc^)+1; 
    FixedRows := 1;



Responder

Gostei + 0

26/08/2009

Emerson Nascimento

Fixed row count must be less than row count;


Abaixo a sugestão de alteração:

var i, j : integer;
    Cresc : ^TCrescimento;
begin
  if IndexIndice = 0 then
    if pgcCapa.ActivePageIndex = 1 then
      if listview.Items.Count > 0 then
        btnTransformadores.Enabled := true
      else
        btnTransformadores.Enabled := false;
  with StringGrid do
  begin 
    if (ListView.Selected = nil) or (ListView.Selected.Data = nil) then
    begin
      FixedCols := 0; // é preciso zerar o numero de colunas fixas
      FixedRows := 0; // é preciso zerar o numero de linhas fixas

      RowCount := 1;
      ColCount := 1;

      Exit;
    end;

    Cresc := ListView.Selected.Data;
    ColCount := Trunc(QtdAnos)+1;
    // verifica se deve fixar a coluna
    if ColCount > 1
      FixedCols := 1
    else
      FixedCols := 0;

    ColWidths[0] := 90;

    for i := 1 to ColCount-1 do
      Cells[i,0] := ´Ano ´+FloatToStr(i);

    RowCount := Length(Cresc^)+1;
    // verifica se deve fixar a linha
    if RowCount > 1
      FixedRows := 1
    else
      FixedRows := 0;

    for i := 0 to length(Cresc^)-1 do
    begin
      SetLength(Cresc^[i].Anos,QtdAnos);
      Cells[0,i+1] := Cresc^[i].NomeClasse;
      for j := 0 to Length(Cresc^[i].Anos)-1 do
      begin
        if Cresc^[i].Anos[J].ValorPorc = 0 then
          Cresc^[i].Anos[J].ValorPorc := 0;
        Cells[j+1,i+1] := FloatToStr(Cresc^[i].Anos[J].ValorPorc);
      end;
    end;
  end;
end;



Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar