Recent

Author Topic: Can not load any data into StringGrid  (Read 3090 times)

GerhardS

  • Newbie
  • Posts: 6
Can not load any data into StringGrid
« on: January 22, 2019, 07:26:50 pm »
Good day, please help with a very strange problem. I am using Lazarus v1.8.4 for Windows.

The problem I am having is that I can not load any data into cells of a StringGrid. I have a StringGrid with Colcount = 5 and Rowcount = 5, I can do a Showmessage in the "OnClick" event of the StringGrid to show each cell's col and row count. However, no matter what I try, I can not get data into any cells, using StringGrid1.cells[col,row] := 'abc' for example. What could be the cause of this problem please, anyone?
« Last Edit: January 22, 2019, 07:31:26 pm by GerhardS »

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Can not load any data into StringGrid
« Reply #1 on: January 22, 2019, 07:40:18 pm »
Is the grid enabled? or is it readonly? or is it visible?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Can not load any data into StringGrid
« Reply #2 on: January 22, 2019, 07:42:36 pm »
Please show more code what you are doing. Or create a small demo project which you can upload here.

The following code, using a StringGrid and a button, is definitively working:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   r, c: Integer;
  4. begin
  5.   c := 1 + Random(StringGrid1.ColCount-1);
  6.   r := 1 + Random(StringGrid1.RowCount-1);
  7.   StringGrid1.Cells[c, r] := IntToStr(Random(1000));
  8. end;  

P.S.
I see now that you are a new user: In order to upload a project, pack the .pas, .lfm, .lpr and .lpi files into a shared .zip, no binaries or any other compiler-generated files, please. Then use "Attachments and other options" to select and upload the zip.
« Last Edit: January 22, 2019, 08:15:35 pm by wp »

GerhardS

  • Newbie
  • Posts: 6
Re: Can not load any data into StringGrid
« Reply #3 on: January 22, 2019, 07:58:55 pm »
Yes the grid is enabled and visible and not readonly

GerhardS

  • Newbie
  • Posts: 6
Re: Can not load any data into StringGrid
« Reply #4 on: January 22, 2019, 08:16:10 pm »
Tried the above sample code....no luck, nothing get loaded into any cells. Could my Lazarus installation be faulty, perhaps?-I dont have any other problems, I have successfully written quite a few apps.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Can not load any data into StringGrid
« Reply #5 on: January 22, 2019, 08:20:40 pm »
Try to recompile the IDE: Go to "Tools" > "Build Lazarus with Profile...". It may take some time after the IDE restarts. Then test again.

GerhardS

  • Newbie
  • Posts: 6
Re: Can not load any data into StringGrid
« Reply #6 on: January 22, 2019, 08:46:32 pm »
I recompiled as suggested, this did not solve my problem.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Can not load any data into StringGrid
« Reply #7 on: January 22, 2019, 09:19:15 pm »
Which other packages are installed? Maybe there is a conflict.

Find out the directory in which the Lazarus settings are stored: "View" > "IDE Internals" > "About IDE". Remember the path given as "Primary config directory". Rename that directory (just to be able to restore it later). Run Lazarus which creates new default settings, no packages installed. Ignore package related error messages or warnings. Rebuild the IDE as described in my previous post.  Repeat the test. If the grid is working now install your packages one by one and find out at which the problems return. If the grid is still not working, restore the old settings by deleting the new config directory and replacing it by the one that you renamed in the beginning; rebuild the IDE again.

GerhardS

  • Newbie
  • Posts: 6
Re: Can not load any data into StringGrid
« Reply #8 on: January 22, 2019, 10:04:30 pm »
I installed LazReport, that's all.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Can not load any data into StringGrid
« Reply #9 on: January 22, 2019, 10:55:51 pm »
Running out of ideas...

Maybe it is easier to reinstall Lazarus, you are on Windows where installation is easy. Make a secondary installation (specify it on one of the first pages of the installer) and reject registration of the file extension, and - of course - install to a different directory and specify a different folder for your user settings - this keeps your first installation untouched, and you later can simply delete the new installation. You can also try the recent release candidate of v2.0 this way.

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Can not load any data into StringGrid
« Reply #10 on: January 22, 2019, 11:10:23 pm »
I installed LazReport, that's all.
upload a demo show casing your problem. If it is part of bigger application please minimize it to the absolutely necessary parts. If for any reason you can not reproduce the problem in a demo then try to reproduce in a new form in the original application. if you can't then delete the old form and recreate from scratch. As it stands now you have not provided enough information to help you solve the problem.

GerhardS

  • Newbie
  • Posts: 6
Re: Can not load any data into StringGrid
« Reply #11 on: January 23, 2019, 06:51:44 pm »
Well I seem to have solved my own problem! I uninstalled Laxarus v1.8.4 and installed a slightly older  v1.6.4 and wallah! Stringgrids now accepting data. So I will stick with v1.6.4 until there is a new version released. Thanks to all who tried to assist.

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Can not load any data into StringGrid
« Reply #12 on: January 23, 2019, 09:32:21 pm »
Well I seem to have solved my own problem! I uninstalled Laxarus v1.8.4 and installed a slightly older  v1.6.4 and wallah! Stringgrids now accepting data. So I will stick with v1.6.4 until there is a new version released. Thanks to all who tried to assist.
that's not a solution, that's not even problem identification but if you are ok with it then happy coding.

 

TinyPortal © 2005-2018