Jump to content


kreggphilpott

Member Since 03 Apr 2019
Offline Last Active Jun 03 2020 12:07 AM
-----

Topics I've Started

OnCellChange Bug with TNxRateColumn6

08 April 2019 - 06:19 PM

I'm trying to react to a change in a TNxRateColumn6.
 
I'm using the OnCellChange event which I assumed was passing in the row and column of the changed cell. This is the case for most column types except for TNxRateColumn6.
 
If there is a better event to respond to rate changes, please let me know. Otherwise, here is my bug report.
 
Attached is a test program showing the issue. The grid is set up with 4 columns as follows:
 
00_Columns.png
 
The FormActivate code fills in some data into the grid:
 
procedure TForm1.FormActivate(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to 4 do
  begin
    nxGrid.AddRow();
    nxGrid.Cell[colShow.Position, i].AsBoolean := true;
    nxGrid.Cell[colLock.Position, i].AsBoolean := false;
    nxGrid.Cell[colRate.Position, i].AsInteger := i mod 5;
    nxGrid.Cell[colRowName.Position, i].AsString := string.Format('Row %d', [i]);
  end;
end;

 
And I added code to report any changes that come through the OnCellChange event:
 
procedure TForm1.nxGridCellChange(Sender: TObject; ACol, ARow: Integer);
var
  msgStr: string;
  nVal: integer;
begin
  if ACol = colRate.Position then
  begin
    nVal := nxGrid.Cell[ACol, ARow].AsInteger;
    msgStr := string.Format('Changed rate cell in row %d Col %d val=%d', [ARow, ACol, nVal]);
  end
  else
  begin

    msgStr := string.Format('Changed cell in row %d Col %d', [ARow, ACol]);
  end;
  ListBox1.Items.Add(msgStr);
  ListBox1.Perform(WM_VSCROLL,SB_BOTTOM,0);
end;

 
The OnCellChange event gets fired during the FormActivate and everything looks OK:
 
01_AfterActivate.png
 
When the application is running, clicking on the checkboxs causes the correct row and column to be reported, but when you click on a TNxrateColumn6 it does strange things. First, it ALWAYS reports the row as the last row no matter which row you click. Second, it reports the incorrect column the first time you click it:
 
02_Click3Row0Col2.png
 
Note that is reports an event on row 4 column 1 (It should be row 0, column 2)
If you click in the same TNxRateColumn6 it will report the column correctly, but the row will still be wrong.
 
03_Click4Row0Col2.png
 
Note that the column is correct, it detected a change in a rate cell, but the row was not. 
Am I not using the events correctly or is there a bug?
 
Thanks for your help!