KnowDotNet Visual Organizer

Enumerating the Items in the TaskList from a Visual Studio .NET Add-in

by Les Smith
Print this Article Discuss in Forums

How can I list the items of the TaskList from a Visual Studio .NET Add-in?  Also, can I list only the high priority items?  The answer is yes to both questions.  The method shown below will list the items in the TaskList that are high priority.  When the compiler generates an error in the TaskList, it gives the description of the error, the ProjectItem FileName, and the line in the file that is in error.  The code shown below lists those properties of the high priority line items from the TaskList.


    Public Sub ListTaskList()
        
Dim win As Window = _
          DTE.Windows.Item(Constants.vsWindowKindTaskList)
        
Dim tskList As TaskList = win.Object
        
Dim tskItem As TaskItem
        
For i As Integer = 1 To tskList.TaskItems.Count
            
With tskList.TaskItems
                
If .Item(i).Priority = _
                   vsTaskPriority.vsTaskPriorityHigh
Then
                    MsgBox(.Item(i).Description & " " & _
                        .Item(i).FileName & " " & _
                        .Item(i).Line)
                
End If
            End With
        Next
    End Sub

Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing