TDBAdvGrid EArgumentOutOfRangeException

I updated to VCL UI Pack from and now a customer is getting the EArgumentOutOfRangeException error (twice today already) using the DBAdvGrid I cannot reproduce it so I cannot provide an example. Maybe you can compare changes you made in the latest version. Customer is using VCL Styles (I see the latest history that something was addressed with that). Here is the stack trace and also note that I do hide columns in my grid if that makes any difference.

Argument out of range.

[00000000005CEB61] System.Classes.TCollection.GetItem (Line 6378, "System.Classes.pas")
[0000000002A17756] DBAdvGrid.TDBGridColumnCollection.GetItem (Line 2023, "DBAdvGrid.pas")
[0000000002A29397] DBAdvGrid.TDBAdvGrid.DoCanEditCell (Line 8144, "DBAdvGrid.pas")
[0000000002938E0D] AdvGrid.TAdvStringGrid.GetCellReadOnly (Line 14353, "AdvGrid.pas")
[0000000002A27FC7] DBAdvGrid.TDBAdvGrid.GetCellReadOnly (Line 7649, "DBAdvGrid.pas")
[00000000029A2F89] AdvGrid.TAdvStringGrid.WMLButtonUp (Line 42270, "AdvGrid.pas")
[0000000000411EA2] System.TObject.Dispatch (Line 18822, "System.pas")
[000000000081A79D] Vcl.Controls.TControl.WndProc (Line 7548, "Vcl.Controls.pas")
[0000000000821C0B] Vcl.Controls.TWinControl.WndProc (Line 10583, "Vcl.Controls.pas")
[00000000029F14FC] AdvGrid.TAdvStringGrid.WndProc (Line 60619, "AdvGrid.pas")
[0000000002A2DD18] DBAdvGrid.TDBAdvGrid.WndProc (Line 9554, "DBAdvGrid.pas")
[0000000000820DAA] Vcl.Controls.TWinControl.MainWndProc (Line 10271, "Vcl.Controls.pas")
[00000000005F4264] System.Classes.StdWndProc (Line 18392, "System.Classes.pas")
[00007FFD66E81C46] USER32 (possible CallWindowProcW+1078)
[00007FFD66E80EA1] USER32 (possible DispatchMessageW+689)
[00000000009D7968] Vcl.Forms.TApplication.ProcessMessage (Line 11336, "Vcl.Forms.pas")
[00000000009D79E4] Vcl.Forms.TApplication.HandleMessage (Line 11366, "Vcl.Forms.pas")
[00000000009CF2A0] Vcl.Forms.TCustomForm.ShowModal (Line 7991, "Vcl.Forms.pas")
[0000000002E2BAFD] Form.BrowseReports.TfrmBrowseReports.DisplayModal (Line 151, "Form.BrowseReports.pas")

I will continue to attempt to duplicate.

Delphi 11.1
VCL Style in use

I cannot reproduce a problem.
Can you try to replace line 9339 with:

  if Assigned(LStyle) and CheckVCLStylesEnabled(LStyle,(csDesigning in ComponentState))  then

to see if this helps?

I noticed in the EurekaLog screen shot that the grid is scrolled to the right and the mouse cursor is in the white space to the right of the grid. So I tried a mouse down on a grid row and sliding the mouse to the right just off the grid and then releasing the button. It took me about 10 tries but I was able to duplicate the argument out of range doing that.
Screen shot snippit:

I will try to trace it down further and then add the change you mentioned to see if that changes anything.

So, it might have just been a coincidence that it starting occurring for this customer after the new update. Probably not typical to have the mouse down and mouse up like that when selecting a row.

Do you have in your application hint related event handling for the grid?
If so, check in your event handler code that you check for ACol,ARow being -1, as this is what the values of these parameters will be when you are over the area where there are no cells.

No, all the Hint related properties of the grid are set to the defaults, with HintShowxxxx all false. Also, no event handlers set for OnOfficeHint or OnScrollHint

The only grid event handlers are:
OnCanSort (checks for ACol > 0)
OnCheckBoxChange, OnCheckBoxClick (checks for ACol and ARow > 0)
OnGetCellColor (checks for ARow > 0 and ACol = 3))
OnSelectCell.(checks for ARow and ACol > 0)

Ok then we will need to have sufficient details to reproduce this.
Please isolate this into a sample source project and send it along with steps how to reproduce.

It is really easy to duplicate now that I found the process. Just have a grid that fits in the space, no horizontal scrollbar, and has some white space to the right of the grid. then mouse down on the last column and slide the mouse to the white space to the right of the last column and lift the mouse. In DoCanEditCell, ACol and ARow are both -1, so the index into Columns[ACol} fails.

procedure TDBAdvGrid.DoCanEditCell(ACol, ARow: Integer; var CanEdit: boolean);

  if (ACol >= Columns.Count) then

  if Columns[ACol].ReadOnly then  << fails here because ACol = -1
    CanEdit := false;

Maybe change the first IF to read:

  if (ACol < 0) or (ACol >= Columns.Count) then

I will also send you an example so you can find the real root of the issue instead of this possible band-aid fix.

In WMLButtonUp and no scrolling, line 42325 (if HasCheckBox), both cx and cy = -1, so it continues to move on instead of exiting or skipping around various code, eventually causing an argument out of range error. When there is a scroll taking place, you get the error when calling GetCellReadOnly at line 42270 as the stack trace showed above.

Still need an example?

Change in your event handler

 if (ACol >= Columns.Count) then


 if (ACol >= Columns.Count) and (ACol >= 0) then

My event handler? What event handler? As mentioned previously, the ones I have already check for ACol > 0. Did you mean for me to change your event handler source code for DoCanEditCell?

And I would add "(ACol < 0)" rather than "(ACol >= 0)"

Sorry, I was confused and this referred to your event handler.
We applied the improvement to check in TDBAdvGrid for ACol < 0.
Next update will have this improvement.