Recent

Author Topic: Stringgrid - don't understand failure to update a cell  (Read 377 times)

jbmckim

  • Full Member
  • ***
  • Posts: 141
Stringgrid - don't understand failure to update a cell
« on: July 23, 2020, 08:17:45 pm »
In the code below strTest updates correctly on the call to ...WvLengthSetting();.  However, the subsequent update of strTest, (i.e. strTest := InputStringGrid.Cells[WAVELENGTH_COL,iWvLngthBeingSet]) returns the value the cell contained prior to the attempted update.  (Insert swearing emoji here.)

This is called from a timer but the grid is in the same Unit as the timer.


Code: Pascal  [Select][+][-]
  1. procedure TExitMainForm.WaveLengthBySpecTimerTimer(Sender: TObject);
  2. const
  3.   WAVELENGTH_COL : integer = 8;
  4. var
  5.   strTest : string = '';
  6.  
  7. begin
  8.  
  9.   if (SpecWvLengthSetupForm.Visible = false) then
  10.    begin
  11.  
  12.      strTest :=  SpecList[iWvLngthBeingSet].WvLengthSetting();
  13.  
  14.  
  15.      InputStringGrid.Cells[WAVELENGTH_COL,iWvLngthBeingSet]
  16.                        := SpecList[iWvLngthBeingSet].WvLengthSetting();
  17.  
  18.      strTest := InputStringGrid.Cells[WAVELENGTH_COL,iWvLngthBeingSet];
  19.  
  20.      iWvLngthBeingSet := -1;
  21.      WaveLengthBySpecTimer.Enabled := false;
  22.    end;
  23.  
  24. end;            

Blaazen

  • Hero Member
  • *****
  • Posts: 3029
  • POKE 54296,15
    • Eye-Candy Controls
Re: Stringgrid - don't understand failure to update a cell
« Reply #1 on: July 23, 2020, 08:37:40 pm »
Code looks fine.  Put breakpoints or writeln(); commands between lines to see what actually is in cell and in strTest.
Lazarus 2.1.0 r64546 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018