Search code examples
delphidelphi-xe2vcl

Delphi XE 2 ActionList - Enable/Disable action


I've created a simple application, which contain: - Main form - Main menu - Action list

Action list consists of three actions: one standard - exit, and two specific - 1. connect to database and 2. billing.

In order to prevent billing action before connecting to database I made property "enabled" for billing = false.

Connect action event (OnExecute) I linked to this procedure:

procedure TForm1.ConnectActionExecute(Sender: TObject);
begin
  ConnectAction.Enabled := false;
  BillingAction.Enabled := true;
  StatusBar1.Panels[0].Text := 'DB Status: Connected';
end;

But after firing this action ConnectAction became disabled, but BillingAction continue to stay disabled. Please point where is my fault?


Solution

  • Do you have an OnExecute event wired to the BillingAction? It is standard behaviour to disable actions with no OnExecute event.

    Update: You can control this with the DisableIfNoHandler property of the action.