Forum > LCL

Out of bounds index error

<< < (2/3) > >>

Al3:

--- Quote from: Zvoni on June 23, 2022, 08:02:58 pm ---Ahh….. „ListView“ is the name of the TStringGrid.

Well, the only thing coming to mind has to do with the (re-) painting of the Form/Grid

--- End quote ---

Yep, in GTK+ that's called a listview so I am used to name it that way :D

repainting of the form should not cause such an error either way. Maybe I did something wrong in the code?
Also most of the properties in Options are enabled.

Handoko:
Game Editor? Wow, glad to know someone is developing it. I was a fan of it and I even made a private class taught my friends how to use it. Game Editor was the first game builder I learned. I still remember, I was so excited after I understood the actor concept and managed to build a simple animation using it.

Now, back to the topic.

I copied, pasted and run the code you provided. Not surprisingly, I didn't get any error as you mentioned. So, can you please provide the source code that can show the issue so we can download, run, inspect and help you?

Al3:

--- Quote from: Handoko on June 23, 2022, 08:38:58 pm ---Game Editor? Wow, glad to know someone is developing it. I was a fan of it and I even made a private class taught my friends how to use it. Game Editor was the first game builder I learned. I still remember, I was so excited after I understood the actor concept and managed to build a simple animation using it.

Now, back to the topic.

I copied, pasted and run the code you provided. Not surprisingly, I didn't get any error as you mentioned. So, can you please provide the source code that can show the issue so we can download, run, inspect and help you?

--- End quote ---

Glad to hear about past members!
I initiated this project not too long ago actually and came out public just this year :)

Back to the topic, what do you mean?
I already posted a link to the entire project folder: https://game-editor2.com/tables.rar   :-[
That shall suffice, right?

Make sure to enable the option to observe this error and I really hope that it can be reproduced.
I am running a fresh Lazarus installation on Win11 and I only installed anchor docking.
But you know.. considering that I consider myself very new to Lazarus and Pascal it is probably something stupid and definitely my fault

Josh:

Try this moded routine, i dont think your given the grid time to update;


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.listviewHeaderClick(Sender: TObject; IsColumn: Boolean; Index: Integer);var    Column   : TGridColumn;begin  If Sender is TStringGrid then  begin    if GetKeyPressed(VK_CONTROL) = FALSE then exit;    if isColumn                  = FALSE then exit;    TStringGrid(Sender).BeginUpdate;    Column := listview.Columns.Add;//TGridColumn.Create(listview.Columns);    Column.Title.Caption := 'Unnamed_' + listview.colCount.toString();    Column.SizePriority := 1;    Column.Index := Index;    Column.Alignment := taCenter;    TStringGrid(Sender).EndUpdate(true);  end;end;              

Al3:

--- Quote from: Josh on June 24, 2022, 01:45:53 am ---
Try this moded routine, i dont think your given the grid time to update;


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.listviewHeaderClick(Sender: TObject; IsColumn: Boolean; Index: Integer);var    Column   : TGridColumn;begin  If Sender is TStringGrid then  begin    if GetKeyPressed(VK_CONTROL) = FALSE then exit;    if isColumn                  = FALSE then exit;    TStringGrid(Sender).BeginUpdate;    Column := listview.Columns.Add;//TGridColumn.Create(listview.Columns);    Column.Title.Caption := 'Unnamed_' + listview.colCount.toString();    Column.SizePriority := 1;    Column.Index := Index;    Column.Alignment := taCenter;    TStringGrid(Sender).EndUpdate(true);  end;end;              
--- End quote ---

Yep, that indeed worked out here.

If I only succeeded to find a source where I could learn about that..
I would've had to deal with that for very long time if I didn't ask here, probably end up ditching this approach entirely.

Also that's a somewhat of a weird pipeline to see (with the code inside BeginUpdate and EndUpdate) and is also still puzzling to me why an error about indexing bounds occurs when I don't give time for the grid to update.

And thanks a lot everyone!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version