MenuCommand.Enabled Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene un valor que indica si el elemento de menú está disponible.
public:
virtual property bool Enabled { bool get(); void set(bool value); };
public virtual bool Enabled { get; set; }
member this.Enabled : bool with get, set
Public Overridable Property Enabled As Boolean
Valor de propiedad
true
si el elemento está habilitado; en caso contrario, false
.
Ejemplos
En el ejemplo de código siguiente se crea un MenuCommand objeto , se configuran sus propiedades y se agregan a 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." );
}
};
}
public class CDesigner : System.ComponentModel.Design.ComponentDesigner
{
public override void Initialize(IComponent comp)
{
base.Initialize(comp);
IMenuCommandService mcs = (IMenuCommandService)comp.Site.
GetService(typeof(IMenuCommandService));
MenuCommand mc = new MenuCommand(new EventHandler(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.");
}
}
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class CDesigner
Inherits System.ComponentModel.Design.ComponentDesigner
Public Overrides Sub Initialize(ByVal comp As IComponent)
MyBase.Initialize(comp)
Dim mcs As IMenuCommandService = CType(comp.Site.GetService(GetType(IMenuCommandService)), IMenuCommandService)
Dim mc As New MenuCommand(New EventHandler(AddressOf OnF1Help), StandardCommands.F1Help)
mc.Enabled = True
mc.Visible = True
mc.Supported = True
mcs.AddCommand(mc)
System.Windows.Forms.MessageBox.Show("Initialize() has been invoked.")
End Sub
Private Sub OnF1Help(ByVal sender As Object, ByVal e As EventArgs)
System.Windows.Forms.MessageBox.Show("F1Help has been invoked.")
End Sub
End Class
Se aplica a
Colaborar con nosotros en GitHub
El origen de este contenido se puede encontrar en GitHub, donde también puede crear y revisar problemas y solicitudes de incorporación de cambios. Para más información, consulte nuestra guía para colaboradores.