Jump to content


Photo

OnCellChange Bug with TNxRateColumn6

OnCellChange TNxRateColumn6

  • Please log in to reply
2 replies to this topic

#1 kreggphilpott

kreggphilpott
  • Members
  • 2 posts

Posted 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!

Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 08 April 2019 - 07:14 PM

Hi,

 

Please update next procedure in NxColumnViewClasses6.pas file, around line 2457:

 

procedure TNxRateColumnView.SetPosition(const Value: Integer);
begin
  if (Value <> -1) and (Value <> Cell.AsInteger) then
  begin
    Owner.LocateCell(Location.X, Location.Y); // <-- new line
    Cell.AsInteger := Value;
    InvalidateRect(ContentRect);
  end;
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 kreggphilpott

kreggphilpott
  • Members
  • 2 posts

Posted 08 April 2019 - 07:40 PM

That fixed it!

 

Thank you very much!






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users