MenuCommand::Enabled Property

 

Gets a value indicating whether this menu item is available.

Namespace:   System.ComponentModel.Design
Assembly:  System (in System.dll)

public:
property bool Enabled {
	virtual bool get();
	virtual void set(bool value);
}

Property Value

Type: System::Boolean

true if the item is enabled; otherwise, false.

The following code example creates a MenuCommand object, configures its properties, and adds it to IMenuCommandService.

   public ref class CDesigner: public ComponentDesigner
   {
   public:
    [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
      virtual void Initialize( IComponent^ comp ) override
      {
         ComponentDesigner::Initialize( comp );
         IMenuCommandService^ mcs = static_cast<IMenuCommandService^>(comp->Site->GetService( IMenuCommandService::typeid ));
		 MenuCommand^ mc = gcnew MenuCommand( gcnew EventHandler( this, &CDesigner::OnF1Help ),StandardCommands::F1Help );
         mc->Enabled = true;
         mc->Visible = true;
         mc->Supported = true;
         mcs->AddCommand( mc );
         System::Windows::Forms::MessageBox::Show( "Initialize() has been invoked." );
      }

   private:
      void OnF1Help( Object^ /*sender*/, EventArgs^ /*e*/ )
      {
         System::Windows::Forms::MessageBox::Show( "F1Help has been invoked." );
      }
   };
}

.NET Framework
Available since 1.1
Return to top
Show: