🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.objectpascal
1 messages
1 total messages Started by Aramis Gunton Wed, 23 Jun 2004 16:14
TStringGrid using deleterow - out of bound
#15
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads