EhLib.Com
https://forum.ehlib.com/en/

ButtonEdit.Enabled in DbGridEh Row is anormaly
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1176
Page 1 of 1

Author:  adriano.quintino [ 16 Sep 2022, 11:20 ]
Post subject:  ButtonEdit.Enabled in DbGridEh Row is anormaly

Hi,

When we scroll the scrollbar below the window boundary, the images that are assigned to the row no longer respect the rules when disabling ButtonEdit.

Attachments:
uTeste.rar [4.01 KiB]
Downloaded 92 times

Author:  EhLibSupport [ 16 Sep 2022, 13:15 ]
Post subject:  Re: ButtonEdit.Enabled in DbGridEh Row is anormaly

Hello

I can't open Form file.
AV in dsnap280.bpl.
Can you create data for DataSet in the code?

Attachments:
sshot-264.png
sshot-264.png [ 88.54 KiB | Viewed 1090 times ]

Author:  adriano.quintino [ 16 Sep 2022, 17:12 ]
Post subject:  Re: ButtonEdit.Enabled in DbGridEh Row is anormaly

EhLibSupport wrote:
Hello

I can't open Form file.
AV in dsnap280.bpl.
Can you create data for DataSet in the code?


Attachments:
uTeste.rar [4.02 KiB]
Downloaded 87 times

Author:  EhLibSupport [ 16 Sep 2022, 21:54 ]
Post subject:  Re: ButtonEdit.Enabled in DbGridEh Row is anormaly

Hello

Code:
procedure TForm1.grdGradeColumns5CellButtons0GetEnabledState(Grid: TCustomDBGridEh;
  Column: TColumnEh; CellButton: TDBGridCellButtonEh; var ButtonEnabled: Boolean);
begin
  ButtonEnabled := not Grid.DataSource.DataSet.IsEmpty and (Grid.DataLink.ActiveRecord = Grid.Row - 1);
  //ButtonEnabled := not Grid.DataSource.DataSet.IsEmpty and (Grid.DataSource.DataSet.RecNo = Grid.Row);
end;


You should use Grid.DataLink.ActiveRecord = Grid.Row - 1 expression to check the current record.
The number of rows in the DBGrid is equal to the number of visible rows.
So when scrolling, RecNo will increase but Grid.Row will not exceed the number of visible rows.

Author:  adriano.quintino [ 16 Sep 2022, 23:48 ]
Post subject:  Re: ButtonEdit.Enabled in DbGridEh Row is anormaly

EhLibSupport wrote:
Hello

Code:
procedure TForm1.grdGradeColumns5CellButtons0GetEnabledState(Grid: TCustomDBGridEh;
  Column: TColumnEh; CellButton: TDBGridCellButtonEh; var ButtonEnabled: Boolean);
begin
  ButtonEnabled := not Grid.DataSource.DataSet.IsEmpty and (Grid.DataLink.ActiveRecord = Grid.Row - 1);
  //ButtonEnabled := not Grid.DataSource.DataSet.IsEmpty and (Grid.DataSource.DataSet.RecNo = Grid.Row);
end;


You should use Grid.DataLink.ActiveRecord = Grid.Row - 1 expression to check the current record.
The number of rows in the DBGrid is equal to the number of visible rows.
So when scrolling, RecNo will increase but Grid.Row will not exceed the number of visible rows.


Thanks so much! I understand.
:D

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/