Fórum Erro num StringGrid #374116
26/08/2009
0
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
Curtir tópico
+ 0Posts
26/08/2009
Osocram
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
Gostei + 0
26/08/2009
Paulo
RowCount := Length(Cresc^)+1; FixedRows := 1;
Gostei + 0
26/08/2009
Osocram
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
RowCount := Length(Cresc^)+1; FixedRows := 1;
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;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)