This is the reason (I presume) why strict private was introduced.
Strict, stricter, strictest

I have a form with a DBGrid and a DBNavigator on it.
dodgebros, does your code in Delphi only work when clicking the navigator? What happens when a user clicks away in the DBGrid?
If the TDBNavigator is the
only control you want to control this behavior on your form, you can easily
hide the navigationbuttons. The following is not ideal but it works:
procedure TForm1.DataSource1StateChange(Sender: TObject);
const
NavigateOptions = [nbFirst, nbPrior, nbNext, nbLast];
begin
if TDataSource(Sender).DataSet.State in [dsEdit, dsInsert] then
DBNavigator1.VisibleButtons := DBNavigator1.VisibleButtons - NavigateOptions
else
DBNavigator1.VisibleButtons := DBNavigator1.VisibleButtons + NavigateOptions;
end;
But... there is another, more elegant option...

The Buttons from TDBNavigator are of type protected
and they are accessible via a class helper.
For example, this would work:
type
TMyDBNavigator = class helper for TDBNavigator
public
procedure DisableButtons(Buttonset: TDBNavButtonSet);
end;
procedure TMyDBNavigator.DisableButtons(Buttonset: TDBNavButtonSet);
var
CurButton: TDBNavButtonType;
begin
for CurButton in Buttonset do
begin
Buttons[CurButton].Enabled := False;
FocusableButtons[CurButton].Enabled := False;
end;
end;
procedure TForm1.DataSource1StateChange(Sender: TObject);
begin
if TDatasource(Sender).State in [dsInsert, dsEdit] then
DBNavigator1.DisableButtons([nbFirst, nbPrior, nbNext, nbLast]);
if TDatasource(Sender).State in [dsEdit] then
DBNavigator1.DisableButtons([nbInsert, nbRefresh, nbDelete]);
if TDatasource(Sender).State in [dsInsert] then
DBNavigator1.DisableButtons([nbRefresh, nbDelete]);
end;
(This last example is more in line with your code but it's one step earlier as it disables the buttons so the user can't click them, so it's more clear to the user. But it only works for when the user wants to use the DBNavigator. Clicking another record in the DBGrid still works, but that was also the case in Delphi.)