本文整理汇总了C#中System.ComponentModel.Design.IDesigner接口的典型用法代码示例。如果您正苦于以下问题:C# IDesigner接口的具体用法?C# IDesigner怎么用?C# IDesigner使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
IDesigner接口属于System.ComponentModel.Design命名空间,在下文中一共展示了IDesigner接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestControl
//引入命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace IDesignerExample
{
// A DesignerAttribute associates the example IDesigner with an example control.
[DesignerAttribute(typeof(ExampleIDesigner))]
public class TestControl : System.Windows.Forms.UserControl
{
public TestControl()
{
}
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
public class ExampleIDesigner : System.ComponentModel.Design.IDesigner
{
// Local reference to the designer's component.
private IComponent component;
// Public accessor to the designer's component.
public System.ComponentModel.IComponent Component
{
get
{
return component;
}
}
public ExampleIDesigner()
{
}
public void Initialize(System.ComponentModel.IComponent component)
{
// This method is called after a designer for a component is created,
// and stores a reference to the designer's component.
this.component = component;
}
// This method peforms the 'default' action for the designer. The default action
// for a basic IDesigner implementation is invoked when the designer's component
// is double-clicked. By default, a component associated with a basic IDesigner
// implementation is displayed in the design-mode component tray.
public void DoDefaultAction()
{
// Shows a message box indicating that the default action for the designer was invoked.
MessageBox.Show("The DoDefaultAction method of an IDesigner implementation was invoked.", "Information");
}
// Returns a collection of designer verb menu items to show in the
// shortcut menu for the designer's component.
public System.ComponentModel.Design.DesignerVerbCollection Verbs
{
get
{
DesignerVerbCollection verbs = new DesignerVerbCollection();
DesignerVerb dv1 = new DesignerVerb("Display Component Name", new EventHandler(this.ShowComponentName));
verbs.Add( dv1 );
return verbs;
}
}
// Event handler for displaying a message box showing the designer's component's name.
private void ShowComponentName(object sender, EventArgs e)
{
if( this.Component != null )
MessageBox.Show( this.Component.Site.Name, "Designer Component's Name" );
}
// Provides an opportunity to release resources before object destruction.
public void Dispose()
{
}
}
}
开发者ID:.NET开发者,项目名称:System.ComponentModel.Design,代码行数:81,代码来源:IDesigner
注:本文中的System.ComponentModel.Design.IDesigner接口示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论