TAdvStringGrid versus zeros

After adding cell data which start with one or multiple zeros (0), the zeros are removed by the TAdvStringGrid. I understand that cells automatically can be converted to integers or floats. I don't know how to disable this option or set a workaround.

I use the following code for setting cell data:

BaseGrid->Cells[Column][Row] = "001234";


The result is:

1234



Thank you in advance for your help.

Applied on a default TAdvStringGrid, the code:

  AdvStringGrid1->Cells[1][1] = "001234";

works as expected. What is different in your app? Did you implement any event handler and if so, what code was used?

An Excel file is imported using TAdvGridExcelIO. The 'ExportCellAsString' is set to true in the 'OnExportColumnFormat' event.

void __fastcall TForm1::GridExcelExportColumnFormat(TObject *Sender, int GridCol,
          int GridRow, int XlsCol, int XlsRow, const WideString Value, bool &ExportCellAsString)
{
  ExportCellAsString = true;
}



The 'FloatFormat' is set to '%.0f' in the 'OnGetFloatFormat' event.

void __fastcall TForm1::BaseGridGetFloatFormat(TObject *Sender, int ACol, int ARow,
          bool &IsFloat, UnicodeString &FloatFormat)
{
  FloatFormat = "%.0f";
}



Using TButton a new column is created and filled with data.

Below a part of the code:

void __fastcall TForm::Button1Click(TObject *Sender)
{
  Screen->Cursor = crHourGlass;
  BaseGrid->BeginUpdate();
  BaseGrid->InsertCols(0, 1);
  for(int i=1; i<BaseGrid->RowCount; i++)
    {
      try
        {
          double dblSomeData = 1;
          BaseGrid->Cells[0][ i ] = (String)FormatFloat("0000000000", (float)dblSomeData);
          // The result is visible as '1' instead of '0000000001'.
        }
      catch(...)
        {
        }
    }
  BaseGrid->EndUpdate();
  Screen->Cursor = crDefault;
}



Do you need more information? Can you please help me out?

The TAdvGridExcelIO option 'ExportCellFormats' is set to 'true'.

With a default TAdvGridExcelIO and just the event handler:

Weird. When I start a new project and drop a TAdvStringGrid and TAdvGridExcelIO on a form and set 'ExportCellAsString' to 'true' everything seems to work properly. I'll rebuild my application to get it properly working. Thank you for your help.

PS. When a cell is in edit mode and the content is a number the editor shows an extra '.00' like a float. (My old application)

Are you referring to edit mode in TAdvStringGrid? I cannot see such issue here with a default grid. What are your EXACT grid property settings and event handler code used?

Is solded the problem by replacing the Grid with a new one. :)