MenuCommand.Supported 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,表示是否支援這個功能表項目。
public:
virtual property bool Supported { bool get(); void set(bool value); };
public virtual bool Supported { get; set; }
member this.Supported : bool with get, set
Public Overridable Property Supported As Boolean
屬性值
如果支援項目 (預設),則為 true
,否則為 false
。
範例
下列程式代碼範例會 MenuCommand 建立 物件、設定其屬性,並將其新增至 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