Add Method (TaskItems Collection)
Visual Studio .NET 2003
Adds a new task item to the Task List.
[Visual Basic .NET]
Public Function Add( _ ByVal Category As String, _ ByVal SubCategory As String, _ ByVal Description As String, _ Optional ByVal Priority As vsTaskPriority = vsTaskPriorityMedium, _ ByVal Icon As Object, _ Optional ByVal Checkable As Boolean = False, _ Optional ByVal File As String = "", _ Optional ByVal Line As Integer = -1, _ Optional ByVal CanUserDelete As Boolean = False, _ Optional ByVal FlushItem As Boolean = True _ ) As TaskItem
[Visual Basic 6]
Function Add( _ ByVal Category As String, _ ByVal SubCategory As String, _ ByVal Description As String, _ Optional ByVal Priority As vsTaskPriority = vsTaskPriorityMedium, _ ByVal Icon As Variant, _ Optional ByVal Checkable As Boolean = False, _ Optional ByVal File As String = "", _ Optional ByVal Line As Long = -1, _ Optional ByVal CanUserDelete As Boolean = False, _ Optional ByVal FlushItem As Boolean = True _ ) As TaskItem
[C++]
HRESULT __stdcall Add( BSTR Category, BSTR SubCategory, BSTR Description, vsTaskPriority Priority, VARIANT Icon, VARIANT_BOOL Checkable, BSTR File, long Line, VARIANT_BOOL CanUserDelete, VARIANT_BOOL FlushItem, /* [out, retval] */ TaskItem** retVal );
[C#]
public TaskItem Add( string Category, string SubCategory, string Description, vsTaskPriority Priority, object Icon, bool Checkable, string File, int Line, bool CanUserDelete, bool FlushItem );
[JScript .NET]
public function Add( Category : String, SubCategory : String, Description : String, Priority : vsTaskPriority, Icon : Object, Checkable : Boolean, File : String, Line : int, CanUserDelete : Boolean, FlushItem : Boolean ) : TaskItem
Parameters
- Category
- Required. Represents the category name of the task item.
- SubCategory
- Required. Represents the subcategory name of the task item.
- Description
- Required. Describes the task item.
- Priority
- Optional. A vsTaskPriority constant denoting the priority of the task item.
- Icon
- Optional. Determines the type of icon that represents the new task item. The setting must be either vsTaskIcon or an IPictureDisp.
- Checkable
- Optional. Indicates whether the new task item is checked. The default value is False.
- File
- 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.
- Line
- 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.
- CanUserDelete
- 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.
- FlushItem
- Optional. Indicates whether a new item is immediately visible in the Task List. The default value is True.
Return Value
Returns a TaskItem object.
Remarks
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.
Example
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, , 10, , )
TLItem = TL.TaskItems.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: " & 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")
TL.TaskItems.Item(1).Delete()
MsgBox("Total number of task items: " & TL.TaskItems.Count)
End Sub
See Also
Applies To: TaskItems Collection