TTMSFNCGrid LoadFromCSVStream and Checkboxes

Hi,

I want to pass data to the Grid using a TMemoryStream.
When I use the LoadFromCSVStream function it loads the data correct. Except the checkboxes are replaced by 'True' and 'False' text values instead of showing the actual checkboxes.

I attached an example.

TestProject.zip (13.9 KB)

Hi,

This is because a CSV file will always be string based. So True and False are actually just the strings and not the boolean value. You can actually use the following code to loop through the cells afterwards and turn them into booleans

  Grid1.LoadFromCSVStream(ms);

  for C := Grid1.FixedColumns to Grid1.ColumnCount - 1 do
  begin
    for R := Grid1.FixedRows to Grid1.RowCount - 1 do
    begin
      s := Grid1.Cells[C, R];
      if (UpperCase(s) = 'TRUE') or (UpperCase(s) = 'FALSE') then
      begin
        Grid1.Cells[C, R] := '';
        Grid1.Booleans[C, R] := StrToBool(s);
      end;
    end;
  end;