CustomTaskPane.Delete 方法 (Office)CustomTaskPane.Delete method (Office)

删除活动的自定义任务窗格。Deletes the active custom task pane.

语法Syntax

表达式删除expression.Delete

_表达式_一个返回**CustomTaskPane** 对象的表达式。expression An expression that returns a CustomTaskPane object.

示例Example

以下示例中,用 C# 编写的创建CustomTaskPane对象的实例,并实现其唯一的方法, CTPFactoryAvailableThe following example, written in C#, creates an instance of a CustomTaskPane object and implements its only method, CTPFactoryAvailable. CTPFactoryAvailableCTPFactory对象传递给外接程序,可以使用外接程序的生存期内使用CreateCTP方法创建任务窗格。CTPFactoryAvailable passes a CTPFactory object to the add-in, which can be used during the add-in's lifetime to create task panes by using the CreateCTP method. 项目还实现用于删除活动的任务窗格的按钮。The project also implements a button that is used to delete the active task pane. 请注意,该示例假定任务窗格是 COM 加载项的一部分,因此可实现Extensibility.IDTExtensibility2Note that the example assumes that the task pane is part of a COM add-in and thus implements Extensibility.IDTExtensibility2. 外接程序也是指一个 Microsoft ActiveX 控件, SampleActiveX.myControl,创建一个单独的项目。The add-in also refers to a a Microsoft ActiveX control, SampleActiveX.myControl, that was created in a separate project.

public class Connect : Object, Extensibility.IDTExtensibility2, ICustomTaskPaneConsumer 
... 
object missing = Type.Missing; 
public CustomTaskPane CTP = null; 
 
public void CTPFactoryAvailable(ICTPFactory CTPFactoryInst) 
{ 
 CTP = CTPFactoryInst.CreateCTP("SampleActiveX.myControl", "Task Pane Example", missing); 
 sampleAX = (myControl)CTP.ContentControl; 
 sampleAX.InsertTextClicked += new InsertTextEventHandler(sampleAX_InsertTextClicked); 
 CTP.Visible = true; 
} 
... 

备注

您可以在任何语言支持 COM 并允许您创建动态链接库 (DLL) 文件; 创建自定义任务窗格例如,Microsoft Visual Basic 6.0、 Visual Basic.NET、 Visual c + +、 Visual c + +.NET,和 Visual C#。You can create custom task panes in any language that supports COM and allows you to create dynamic-linked library (DLL) files; for example, Microsoft Visual Basic 6.0, Visual Basic .NET, Visual C++, Visual C++ .NET, and Visual C#. 但是,Microsoft Visual Basic for Applications (VBA) 不支持创建自定义任务窗格。However, Microsoft Visual Basic for Applications (VBA) does not support creating custom task panes.

另请参阅See also