ActionListの使用方法

 

別のコントロールで同じアクションを実行
アクションの使用可・不可を設定

アクションの使用可・不可を設定

1/2
1/2
アプリケーションの状態に応じてアクションを使用可/使用不可にすることでコントロールの状態も制御できます。

ファイルがClose状態のときには、[Open]ボタンは有効で[Close]ボタンは無効、
ファイルがOpen 状態のときには、[Open]ボタンは無効で[Close]ボタンは有効になるように設定してみましょう。

ActionのEnabledプロパティで 有効/無効を設定しますが、OnUpdateイベントで記述します。


 
procedure TForm1.Action1Update(Sender: TObject);
begin
  if not Query1.Active then
    Action1.Enabled := True
  else
    Action1.Enabled := False;


(または Action1.Enabled := not Query1.Active;) end;
procedure TForm1.Action2Update(Sender: TObject); begin if Query1.Active then Action2.Enabled := True else Action2.Enabled := False;
(または Action2.Enabled := Query1.Active;) end;


 
1/2