Compartir a través de


TaskItems2.Add2 Method

Definition

Overloads

Add2(String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean, Boolean)
Add2(String, String, String, Int32, Object, Boolean, String, Int32, Boolean, Boolean, Boolean)

Adds a new task item to the TaskList.

Add2(String, String, String, vsTaskPriority, Object, Boolean, String, Int32, Boolean, Boolean, Boolean)

[System.Runtime.InteropServices.DispId(7)]
public EnvDTE.TaskItem Add2 (string Category, string SubCategory, string Description, EnvDTE.vsTaskPriority Priority, object Icon, bool Checkable = false, string File = "", int Line = -1, bool CanUserDelete = true, bool FlushItem = true, bool AutoNavigate = false);
[<System.Runtime.InteropServices.DispId(7)>]
abstract member Add2 : string * string * string * EnvDTE.vsTaskPriority * obj * bool * string * int * bool * bool * bool -> EnvDTE.TaskItem
Public Function Add2 (Category As String, SubCategory As String, Description As String, Priority As vsTaskPriority, Optional Icon As Object, Optional Checkable As Boolean = false, Optional File As String = "", Optional Line As Integer = -1, Optional CanUserDelete As Boolean = true, Optional FlushItem As Boolean = true, Optional AutoNavigate As Boolean = false) As TaskItem

Parameters

Category
String
SubCategory
String
Description
String
Priority
vsTaskPriority
Icon
Object
Checkable
Boolean
File
String
Line
Int32
CanUserDelete
Boolean
FlushItem
Boolean
AutoNavigate
Boolean

Returns

Attributes

Remarks

The Priority defaults to vsTaskPriorityMedium in IDL but we can't default it here as the Icon cannot be defaulted

Applies to

Add2(String, String, String, Int32, Object, Boolean, String, Int32, Boolean, Boolean, Boolean)

Adds a new task item to the TaskList.

EnvDTE::TaskItem Add2(std::wstring const & Category, std::wstring const & SubCategory, std::wstring const & Description, int Priority = 2, winrt::Windows::Foundation::IInspectable const & Icon, bool Checkable = false, std::wstring const & File = "", int Line = -1, bool CanUserDelete = true, bool FlushItem = true, bool AutoNavigate = false);
[System.Runtime.InteropServices.DispId(7)]
public EnvDTE.TaskItem Add2 (string Category, string SubCategory, string Description, int Priority = 2, object Icon, bool Checkable = false, string File = "", int Line = -1, bool CanUserDelete = true, bool FlushItem = true, bool AutoNavigate = false);
[<System.Runtime.InteropServices.DispId(7)>]
abstract member Add2 : string * string * string * int * obj * bool * string * int * bool * bool * bool -> EnvDTE.TaskItem
Public Function Add2 (Category As String, SubCategory As String, Description As String, Optional Priority As Integer = 2, Optional Icon As Object, Optional Checkable As Boolean = false, Optional File As String = "", Optional Line As Integer = -1, Optional CanUserDelete As Boolean = true, Optional FlushItem As Boolean = true, Optional AutoNavigate As Boolean = false) As TaskItem

Parameters

Category
String

Required. Represents the category name of the task item.

SubCategory
String

Required. Represents the subcategory name of the task item.

Description
String

Required. Describes the task item.

Priority
Int32

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.

Icon
Object

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

Checkable
Boolean

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.

File
String

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[vsTaskListColumn](vsTaskListColumnFile) returns false. The file name can be a full path, a relative path, or simply a file name. Note that associating a file or path with an item does not necessarily mean that it performs any actions.

Line
Int32

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[vsTaskListColumn](vsTaskListColumnLine) returns false. Note that associating a line number with an item does not necessarily mean that it performs any actions.

CanUserDelete
Boolean

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
Boolean

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.

AutoNavigate
Boolean

Optional. Indicates whether the TaskItem has the AutoNavigate feature enabled. AutoNavigate is on when this is set to true; otherwise, false.

Returns

A TaskItem object.

Attributes

Examples

Imports EnvDTE  
Imports EnvDTE80  
Sub TaskItemsAdd2Example(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 using Add2.  
    TLItem = TLItems.Add2(" ", " ", "Test task 1." _  
    , vsTaskPriority.vsTaskPriorityHigh, vsTaskIcon.vsTaskIconUser _  
    , True, , 10, , , False)  
        TLItem = TLItems.Add2(" ", " ", "Test task 2." _  
    , vsTaskPriority.vsTaskPriorityLow, vsTaskIcon.vsTaskIconComment _  
    , , , 20, , , False)  
    ' 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 TaskItems2Add2Example(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.Add2("MyTask", "MyTask1", "Test task 1."  
, 1, vsTaskIcon.vsTaskIconUser, true,null,10,true,true,true);  
TLItem = TLItems.Add2("MyTask", "MyTask1", "Test task 2."  
, 2, vsTaskIcon.vsTaskIconComment, true, null, 20, true, true,false);  
    // 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);  
}  

Remarks

When adding bitmaps, the RGB color 0x0000FF00 (green) is transparent. All places in your picture that use this value are transparent and the Task List shows 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 Metafiles, Uninitialized, or None do not work correctly.

Applies to