CustomTaskPane 方法 (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 加载项的一部分, 从而实现了可扩展性。 IDTExtensibility2Note that the example assumes that the task pane is part of a COM add-in and thus implements Extensibility.IDTExtensibility2. 外接程序还引用在单独的项目中创建的 Microsoft ActiveX 控件SampleActiveX myControlThe add-in also refers to 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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.