Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
[Solved]TStringGrid EGridException index out of range.
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Using WriteLn inside dll
by
DelphiDinosaur
[
Today
at 01:40:00 pm]
fpsockets error: 10047
by
rvk
[
Today
at 01:27:41 pm]
Avoid system units debugg...
by
janasoft
[
Today
at 12:13:42 pm]
Struggling with Orthello/...
by
Dzandaa
[
Today
at 11:48:43 am]
[SOLVED] progress dialog ...
by
Phoenix
[
Today
at 11:14:23 am]
Hello everyone!
by
MarsvinEvini
[
Today
at 10:22:00 am]
Notetask 1.1.0 - Free cro...
by
AlexanderT
[
Today
at 10:05:28 am]
I cannot save an unit on ...
by
Zvoni
[
Today
at 09:06:05 am]
Mapping Images Like Odome...
by
circular
[
Today
at 08:58:33 am]
Matching video to form
by
paweld
[
Today
at 08:44:46 am]
Introducing PasBuild 1.0....
by
Thaddy
[
Today
at 08:16:53 am]
Form adjusting to screen ...
by
RickSpink
[
Today
at 08:11:59 am]
Amigo programming languag...
by
paxscript
[
Today
at 04:06:34 am]
Feature better than a new...
by
TBMan
[
Today
at 03:56:13 am]
Any way to exclude terms ...
by
n7800
[
Today
at 12:59:05 am]
Just Curious: When has an...
by
n7800
[
Today
at 12:15:00 am]
Detect orphaned procedure...
by
Martin_fr
[December 09, 2025, 11:37:51 pm]
modern main menu
by
n7800
[December 09, 2025, 10:23:04 pm]
Is FPGUI still active?
by
Fred vS
[December 09, 2025, 09:29:08 pm]
Lazarus Bugfix Release 4...
by
Martin_fr
[December 09, 2025, 08:35:41 pm]
Hints in TTrayIcon
by
avra
[December 09, 2025, 07:01:02 pm]
Problem with TSQLQuery
by
sch61
[December 09, 2025, 05:15:38 pm]
What are some good modern...
by
sanric
[December 09, 2025, 04:46:09 pm]
First PythonForLazarus De...
by
fozkan
[December 09, 2025, 04:20:56 pm]
problem with zquery
by
Gebo
[December 09, 2025, 02:59:47 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved]TStringGrid EGridException index out of range. (Read 409 times)
cov
Full Member
Posts: 246
[Solved]TStringGrid EGridException index out of range.
«
on:
September 29, 2025, 10:26:19 am »
I'm probably doing something really, really stupid.
Code: Pascal
[Select]
[+]
[-]
fpaths
:
=
TStringList
.
Create
;
fpaths
.
Delimiter
:
=
';'
;
fpaths
.
StrictDelimiter
:
=
True
;
fpaths
.
DelimitedText
:
=
INI
.
ReadString
(
'Font paths'
,
'paths'
,
''
)
;
StringGrid1
.
Width
:
=
GroupBox1
.
Width
-
16
;
for
i
:
=
0
to
fpaths
.
Count
-
1
do
begin
if
fpaths
.
Strings
[
i
]
<>
''
then
StringGrid1
.
InsertRowWithValues
(
n
,
[
fpaths
.
Strings
[
i
]
]
)
;
end
;
Can anyone advise me what it is?
I've tried setting the rowCount to 1 and clearing it with TStringGrid.Clear.
«
Last Edit: September 29, 2025, 11:42:26 am by cov
»
Logged
Lutz Mändle
Jr. Member
Posts: 83
Re: TStringGrid EGridException index out of range.
«
Reply #1 on:
September 29, 2025, 10:43:39 am »
Where is n from in
Code: Pascal
[Select]
[+]
[-]
StringGrid1
.
InsertRowWithValues
(
n
,
[
fpaths
.
Strings
[
i
]
]
)
;
I guess, it should be i.
Logged
Zvoni
Hero Member
Posts: 3187
Re: TStringGrid EGridException index out of range.
«
Reply #2 on:
September 29, 2025, 10:54:58 am »
*sigh*
Code: Pascal
[Select]
[+]
[-]
for
i
:
=
0
to
fpaths
.
Count
-
1
do
//You are using "i" as iterator
begin
if
fpaths
.
Strings
[
i
]
<>
''
then
StringGrid1
.
InsertRowWithValues
(
n
,
[
fpaths
.
Strings
[
i
]
]
)
;
//You are using "n" as Row-Identifier
end
;
Spot the mistake
EDIT: Why even in such a convoluted way with that InsertRowWithValues?
Why not read the INI-Stuff into a FileStream, and then use LoadFromCSVStream?
https://lazarus-ccr.sourceforge.io/docs/lcl/grids/tcustomstringgrid.loadfromcsvstream.html
«
Last Edit: September 29, 2025, 11:03:42 am by Zvoni
»
Logged
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
cov
Full Member
Posts: 246
Re: TStringGrid EGridException index out of range.
«
Reply #3 on:
September 29, 2025, 11:41:56 am »
Thanks,
Well spotted.
Yes the 'n' was a legacy item in my code that I hadn't noticed.
The reason that I'm loading from an INI file is that I have multiple items and the Font paths are just one of them.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
[Solved]TStringGrid EGridException index out of range.
TinyPortal
© 2005-2018