🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #15

TStringGrid using deleterow - out of bound

#15
From: Aramis Gunton
Date: Wed, 23 Jun 2004 16:14
43 lines
2297 bytes
Probably an old chestnut but I need help.

I have a TStringGrid that requires a delete row feature.

I have used the grid hack to gain access to "deleterow" which indeed
removes the selected row however subsequent to the deletion the row now
occupying the deleted rows position is inaccessible.

StringGrid1.rows[deletedposition] returns ([(out of bound) 2, (out of
bound) 4], #0. #0, 0 nil) as opposed to ([], #0, #0, 0, nil) for all of
the other rows.

I have tried many ways available via Google yet this problem keeps
occurring.

Essentially the string grid contains details of delivery notes which are
entered via TEdits. Each entry is checked to ensure it has not already
been entered.

The function is below - sTemp ends up as say "004564"

function TFormPOD.IsUnique:Boolean;
var
  sTemp : String;
  i     : integer;
begin
     Result := True;
     sTemp := ToStr(StrToInt(DNote.Text),6);
     with StringGrid1 do
       for I := 0 to rowcount -1 do begin
         if rows[i].IndexOf(sTemp) <> -1 then
           Result := False;
       end;
end;

After any deletion the rows.IndexOf[deletedposition] line gives an
Access Violation Error due to the "out of bound" feature explained
above.

Any insight greatly appreciated or even better a simple example of a
successful deletion of a row from a TStringGrid that leaves it stable.
-- 
Aramis Gunton
Technical Details
Message-ID: <v+HKAFkixa2AFwMm@nink.demon.co.uk>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.159.246.34.MISMATCH!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!nink.demon.co.uk!aramis

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,f2e6a55be3d8f1a4,start
X-Google-Attributes: gid109d30,public
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.159.246.34.MISMATCH!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!nink.demon.co.uk!aramis
From: Aramis Gunton <aramis@nink.demon.co.uk>
Newsgroups: borland.public.delphi.language.objectpascal
Subject: TStringGrid using deleterow - out of bound
Date: Wed, 23 Jun 2004 17:14:26 +0100
Lines: 43
Message-ID: <v+HKAFkixa2AFwMm@nink.demon.co.uk>
NNTP-Posting-Host: nink.demon.co.uk
Mime-Version: 1.0
Content-Type: text/plain;charset=us-ascii
X-Trace: news.demon.co.uk 1088007279 4648 80.176.234.174 (23 Jun 2004 16:14:39 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 23 Jun 2004 16:14:39 +0000 (UTC)
User-Agent: Turnpike/6.02-S (<JtxdWzY$xnJXyYnEBXEOoeQFuZ>)