This documentation is archived and is not being maintained.

TaskItems.Add Method

Adds a new task item to the TaskList.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

TaskItem Add (
	[InAttribute] string Category,
	[InAttribute] string SubCategory,
	[InAttribute] string Description,
	[OptionalAttribute] [InAttribute] vsTaskPriority Priority,
	[OptionalAttribute] [InAttribute] Object Icon,
	[OptionalAttribute] [InAttribute] bool Checkable,
	[OptionalAttribute] [InAttribute] string File,
	[OptionalAttribute] [InAttribute] int Line,
	[OptionalAttribute] [InAttribute] bool CanUserDelete,
	[OptionalAttribute] [InAttribute] bool FlushItem
TaskItem Add (
	/** @attribute InAttribute() */ String Category, 
	/** @attribute InAttribute() */ String SubCategory, 
	/** @attribute InAttribute() */ String Description, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ vsTaskPriority Priority, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ Object Icon, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ boolean Checkable, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String File, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int Line, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ boolean CanUserDelete, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ boolean FlushItem
function Add (
	Category : String, 
	SubCategory : String, 
	Description : String, 
	Priority : vsTaskPriority, 
	Icon : Object, 
	Checkable : boolean, 
	File : String, 
	Line : int, 
	CanUserDelete : boolean, 
	FlushItem : boolean
) : TaskItem



Required. Represents the category name of the task item.


Required. Represents the subcategory name of the task item.


Required. Describes the task item.


Optional. A vsTaskPriority constant denoting the priority of the task item (high, medium, or low). If the value is vsTaskPriorityHigh, an exclamation point icon is displayed in the first column of the Task List. If the value is vsTaskPriorityMedium, nothing is displayed. If the value is vsTaskPriorityLow, a down arrow icon is displayed.


Optional. Determines the type of icon that represents the new task item. The setting must be either vsTaskIcon or an IPictureDisp.


Optional. Indicates whether or not you want the task item to provide a checkbox that users can check to indicate the task is complete. The default value is false.


Optional. Indicates the file or path associated with the new task item. The default value is an empty string (""), and if this is used, IsSettable(vsTaskListColumnFile) returns false. The file name can be a full path name, a relative path name, or simply a file name. Note that associating a file or path with an item does not necessarily mean that it will perform any actions.


Optional. Indicates the line in the source code associated with the new task item. The default value is 0, and if this is used, IsSettable(vsTaskListColumnLine) returns false. Note that associating a line number with an item does not necessarily mean that it will perform any actions.


Optional. Indicates whether a user can delete the new task item by pressing DELETE when the item is selected in the environment. The default value is true.


Optional. Indicates whether a new item is immediately visible in the Task List. When FlushItem is set to True, the Task List is updated immediately after Add is called. When FlushItem is set to false, the Task List is updated later after all updates are made. A false setting is used primarily to enhance performance when you are adding a large number of items at a time to the Task List. The default value is true.

Return Value

A TaskItem object.

When adding bitmaps, the RGB color 0x0000FF00 (green) is transparent. All places in your picture that use this value will be transparent and the Task List will show through.

The width and height of bitmaps must be 16 x 16 pixels.

If using IPictureDisp, the PICTYPE argument must be set to either Icon or Bitmap. Settings of either Metafiles, Uninitialized, or None will not work correctly.

Sub TaskItemsAddExample1()
   Dim win As Window = DTE.Windows.Item(Constants.vsWindowKindTaskList)
   Dim TL As TaskList = win.Object
   Dim TLItem As TaskItem

   ' Add a couple of tasks to the Task List.
   TLItem = TL.TaskItems.Add(" ", " ", "Test task 1.", _
   vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser, True, _
   "c:\temp.txt", 10, , )
   TLItem = TL.TaskItems.Add(" ", " ", "Test task 2.", _
   vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment, _
   False, "c:\temp2.txt", 20, , )
   ' List the total number of task list items after adding the new 
   ' task items.
   MsgBox("Task Item 1 description: " & TL.TaskItems.Item(2).Description)
   MsgBox("Total number of task items: " & TL.TaskItems.Count)

   ' Remove the second task item. The items list in reverse numeric order.
   MsgBox("Deleting the second task item")
   MsgBox("Total number of task items: " & TL.TaskItems.Count)
End Sub