advstringgrid nodes clear

Dear all,



I'l try to use advstringgrid with nodes



    savefixedcells := false;

    loadfromcsv(fileName);

    i := 1; j := 1;

    while (i < rowcount - 1) do

    begin

      s := cells[1, j];

      while (cells[1, j] = cells[1, j + 1]) and (j < rowcount - 1) do inc(j);

      if (i <> j) then AddNode(i, j - i + 1);

      i := j + 1;

      j := i;

    end;

    fixedcols := 0;

    row := 1; col := 1;

end;



first time everything is ok,

if I try to read again the nodes don't work well

it is as if they are not removed nodes preceding





thank you for your help



Giorgio Marino



I do not see in your code that you remove the nodes.

Can you try to call grid.RemoveAllNodes before starting to load & add nodes in the grid?

Dear partner,



Try to use your example: TMSPack\Samples\AdvStringGrid\asg11



insert a buttom with:



var

i, j: integer;

begin

with advstringgrid1 do

begin

    savefixedcells := false;

    loadfromcsv('cars.csv');

    autosizecolumns(true, 10);

    ColWidths[0] := 20;

    i := 1; j := 1;

    while (i < rowcount - 1) do

    begin

      if cells[1, j] = 'BMW' then bmwnode := j;

      while (cells[1, j] = cells[1, j + 1]) and (j < rowcount - 1) do inc(j);

      if (i <> j) then AddNode(i, j - i + 1);

      i := j + 1;

      j := i;

    end;

    fixedcols := 0;

    row := 1; col := 1;

end;



first time stringgrid have nodes ok, other times if I call this button nodes don't work well



b.r.

Giorgio

If you want an identical situation as on startup, please use the code:


procedure TForm1.Button5Click(Sender: TObject);
var
  i, j: integer;
begin
  with advstringgrid1 do
  begin
    RemoveAllNodes;
    fixedcols := 1;
    savefixedcells := false;
    loadfromcsv('cars.csv');
    autosizecolumns(true, 10);
    ColWidths[0] := 20;
    i := 1; j := 1;
    while (i < rowcount - 1) do
    begin
      if cells[1, j] = 'BMW' then bmwnode := j;
      while (cells[1, j] = cells[1, j + 1]) and (j < rowcount - 1) do inc(j);
      if (i <> j) then AddNode(i, j - i + 1);
      i := j + 1;
      j := i;
    end;
    fixedcols := 0;
    row := 1;
    col := 1;
  end;
end;

Thank you very much



works well!



b.r.

Giorgio