Export (0) Print
Expand All

TaskItems2 Interface

The TaskItems collection contains all of the tasks in the Task List window.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

[GuidAttribute("B820F931-645A-473F-8246-922CF069E1FE")]
public interface TaskItems2 : TaskItems

The TaskItems2 type exposes the following members.

  NameDescription
Public propertyCountGets a value indicating the number of objects in the collection.
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of a TaskItems collection.
Top

  NameDescription
Public methodAddAdds a new task item to the TaskList.
Public methodAdd2Adds a new task item to the TaskList.
Public methodForceItemsToTaskListSends all task items to the Task List that haven't been added.
Public methodGetEnumeratorGets an enumeration for items in a collection.
Public methodItemReturns an indexed member of a TaskItems collection.
Top

This example adds two task items to the task list and displays some of their properties in message boxes. For more information about how to run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

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);
}

Community Additions

ADD
Show:
© 2014 Microsoft