1 (edited by dhekabai 2020-10-01 09:32:32)

Topic: List Index out of Bounds (2) error message.

I have a form with a TableGrid, double-clicking a record used to view the record in a different form. But now when I double-click, or click the Show Record button it shows the error message first, and when I close it, it opens the edit screen like normal. I haven't changed as far as I know.

Please see the screenshot: imgur. com/rmx5EpW

How do I fix this?

Re: List Index out of Bounds (2) error message.

dhekabai,

If you have some kind of loop in the double click event you may have counted the records incorrectly.

Could you post your code for this event? That would help us to point you in the right direction.

Generally speaking if you have counted how many records are in your table, you need to have a max_count of record_ count - 1.

On a clear disk you can seek forever

3 (edited by dhekabai 2020-10-01 09:37:54)

Re: List Index out of Bounds (2) error message.

I have no other events or procedures scripted on the TableGrid, The only scripts I'm using are to resize columns when the form shows.

Here is my script:




procedure newentry_OnShow (Sender: TObject; Action: string);
begin

    newentry.TableGrid1.Columns[0].Width :=   120;
    newentry.TableGrid1.Columns[1].Width :=   120;
    newentry.TableGrid1.Columns[2].Width :=   100;
    newentry.TableGrid1.Columns[3].Width :=   315;

end;

procedure Form1_OnShow (Sender: string; Action: string);
begin
    Form1.TableGrid1.Columns[0].Width := 80;
    Form1.TableGrid1.Columns[1].Width := 90;
    Form1.TableGrid1.Columns[2].Width := 90;
    Form1.TableGrid1.Columns[3].Width := 130;
    Form1.TableGrid1.Columns[4].Width := 130;
    Form1.TableGrid1.Columns[5].Width := 74;
    Form1.TableGrid1.Columns[6].Width := 62;
end;

begin


end.

P.S. Now I get the message even when I click the edit record button.



EDIT: It seems like a bug in the program: The TableGrid I'm selecting the record from has only Name and Second Name fields. But I want to show complete details in the edit record form. But it isn't able to detect all the fields, but only the ones in the previous screen. SO column 3 doesn't exist, and hence can't be resized. So I get that error.

I have attached the project below.

Post's attachments

Attachment icon Project1.rar 296.77 kb, 201 downloads since 2020-10-01 

Re: List Index out of Bounds (2) error message.

Anyone?

5 (edited by derek 2020-10-02 12:43:18)

Re: List Index out of Bounds (2) error message.

There is no bug in the program.
When you add a new record using the 'newentry' form, your tablegrid has 4 columns so there is no problem. 
When you edit a record, because you have (for some reason) added a 'search' button to your 'newentry' form, MVD uses the tablegrid layout associated with that 'search' button - and that layout only has 2 columns and so you get your error message (see attached screenshot).

Post's attachments

Attachment icon screenshot1.jpg 224.77 kb, 96 downloads since 2020-10-02 

Re: List Index out of Bounds (2) error message.

Ok, wow that was real retarded of me not to realise, but if it's any excuse, I am very new to the program, so apologies!

I can work around this by just using a new form for creating a new record(with a search button) and this existing one to edit it, right?

Again, thanks, and apologies! Absolutely love the program, it's like nothing I've ever used in both ease of use and flexibility.