TaskItems2 介面
TaskItems 集合包含 [工作清單] 視窗中的所有工作。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
<GuidAttribute("B820F931-645A-473F-8246-922CF069E1FE")> _
Public Interface TaskItems2 _
Inherits TaskItems
[GuidAttribute("B820F931-645A-473F-8246-922CF069E1FE")]
public interface TaskItems2 : TaskItems
[GuidAttribute(L"B820F931-645A-473F-8246-922CF069E1FE")]
public interface class TaskItems2 : TaskItems
[<GuidAttribute("B820F931-645A-473F-8246-922CF069E1FE")>]
type TaskItems2 =
interface
interface TaskItems
end
public interface TaskItems2 extends TaskItems
TaskItems2 型別會公開下列成員。
屬性
名稱 | 說明 | |
---|---|---|
Count | (繼承自 TaskItems)。 | |
Count | 取得數值,指出集合中物件的數目。 | |
DTE | (繼承自 TaskItems)。 | |
DTE | 取得最上層的擴充性物件。 | |
Parent | (繼承自 TaskItems)。 | |
Parent | 取得 TaskItems 集合的直接上層父物件。 |
回頁首
方法
名稱 | 說明 | |
---|---|---|
Add(String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean) | (繼承自 TaskItems)。 | |
Add(String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean) | 將新的工作項目加入至 TaskList 中。 | |
Add2 | 將新的工作項目加入至 TaskList 中。 | |
ForceItemsToTaskList() | (繼承自 TaskItems)。 | |
ForceItemsToTaskList() | 將尚未加入的所有工作項目傳送到 [工作清單]。 | |
GetEnumerator() | (繼承自 TaskItems)。 | |
GetEnumerator() | 取得列舉集合中的項目。 | |
Item(Object) | (繼承自 TaskItems)。 | |
Item(Object) | 傳回 TaskItems 集合的索引成員。 |
回頁首
範例
這個範例會將兩個工作項目加入至工作清單中,並在訊息視窗中顯示這兩個項目的某些屬性。 如需如何像執行增益集一般,執行這個範例的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。
Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
TaskItems2Example(_applicationObject)
End Sub
Sub TaskItems2Example(ByVal dte As DTE2)
Dim win As Window = _applicationObject.Windows.Item _
(Constants.vsWindowKindTaskList)
Dim TL As TaskList = CType(win.Object, TaskList)
Dim TLItem As TaskItem
Dim TLItems As TaskItems2
TLItems = CType(TL.TaskItems, TaskItems2)
' Add a couple of tasks to the Task List.
TLItem = TLItems.Add(" ", " ", "Test task 1.", _
vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser _
, True, , 10, , )
TLItem = TLItems.Add(" ", " ", "Test task 2." _
, vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment _
, , , 20, , )
' List the total number of task list items after adding the new
' task items.
MsgBox("Task Item 1 description: " & TLItems.Item(2).Description)
MsgBox("Total number of task items: " & TLItems.Count)
' Remove the second task item.
' The items list in reverse numeric order.
MsgBox("Deleting the second task item")
TLItems.Item(1).Delete()
MsgBox("Total number of task items: " & TLItems.Count)
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
TaskItems2Example(_applicationObject);
}
public void TaskItems2Example(DTE2 dte)
{
Window2 win = (Window2)_applicationObject.Windows.Item
(Constants.vsWindowKindTaskList);
TaskList TL = (TaskList)win.Object;
TaskItem TLItem;
TaskItems2 TLItems;
TLItems = (TaskItems2)TL.TaskItems;
// Add a couple of tasks to the Task List.
TLItem = TLItems.Add("MyTask", "MyTask1", "Test task 1."
, vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser
, true,null,10,true,true );
TLItem = TLItems.Add("MyTask", "MyTask1", "Test task 2."
, vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment
, true, null, 20, true, true);
// List the total number of task list items after adding the new
// task items.
MessageBox.Show("Task Item 1 description: " +
TLItems.Item(2).Description);
MessageBox.Show("Total number of task items: "
+ TLItems.Count.ToString());
// Remove the second task item.
// The items list in reverse numeric order.
MessageBox.Show("Deleting the second task item");
TLItems.Item(1).Delete();
MessageBox.Show("Total number of task items: " + TLItems.Count);
}