Compartir a través de


TaskItems2.Count (Propiedad)

Obtiene un valor que indica el número de objetos de la colección.

Espacio de nombres:  EnvDTE80
Ensamblado:  EnvDTE80 (en EnvDTE80.dll)

Sintaxis

'Declaración
ReadOnly Property Count As Integer
int Count { get; }
property int Count {
    int get ();
}
abstract Count : int
function get Count () : int

Valor de propiedad

Tipo: System.Int32
El número de objetos de la colección TaskItems.

Ejemplos

Este ejemplo agrega dos elementos de tarea a la lista de tareas y muestra algunas de sus propiedades, incluida la propiedad Count en cuadros de mensaje.Para obtener más información sobre cómo ejecutar este ejemplo como un complemento, vea Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización.

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

Seguridad de .NET Framework

Vea también

Referencia

TaskItems2 Interfaz

Count (Sobrecarga)

EnvDTE80 (Espacio de nombres)