(SPView) del método SPList.GetItems
Devuelve una colección de elementos de la lista basándose en la vista especificada.
Espacio de nombres: Microsoft.SharePoint
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Function GetItems ( _
view As SPView _
) As SPListItemCollection
'Uso
Dim instance As SPList
Dim view As SPView
Dim returnValue As SPListItemCollection
returnValue = instance.GetItems(view)
public SPListItemCollection GetItems(
SPView view
)
Parámetros
view
Tipo: Microsoft.SharePoint.SPViewLa vista para usar en la selección de elementos de lista.
Valor devuelto
Tipo: Microsoft.SharePoint.SPListItemCollection
Los elementos de lista especificados por la vista.
Excepciones
Excepción | Condición |
---|---|
ArgumentNullException | view es nulo (NothingVisual Basic ). |
Ejemplos
En el siguiente ejemplo es una aplicación de consola que usa la vista "Mis tareas" de la lista de tareas para recuperar elementos de lista. Después de recuperar los datos, la aplicación imprime un informe sencillo en la consola.
Imports System
Imports System.Collections.Specialized
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As SPSite = New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
' Get data from a list.
Dim listUrl As String = web.ServerRelativeUrl + "/lists/tasks"
Dim list As SPList = web.GetList(listUrl)
Dim view As SPView = list.Views("My Tasks")
Dim items As SPListItemCollection = list.GetItems(view)
' Get a collection of view field names.
Dim viewFields As StringCollection = view.ViewFields.ToStringCollection()
' Print data for each item in the view.
Dim item As SPListItem
For Each item In items
' Print the value of each view field.
Dim fieldName As String
For Each fieldName In viewFields
Console.WriteLine("{0} = {1}", fieldName, item(fieldName))
Next fieldName
Console.WriteLine()
Next item
End Using
End Using
Console.ReadLine()
End Sub
End Module
using System;
using System.Collections.Specialized;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
// Get data from a list.
string listUrl = web.ServerRelativeUrl + "/lists/tasks";
SPList list = web.GetList(listUrl);
SPView view = list.Views["My Tasks"];
SPListItemCollection items = list.GetItems(view);
// Get a collection of view field names.
StringCollection viewFields = view.ViewFields.ToStringCollection();
// Print data for each item in the view.
foreach (SPListItem item in items)
{
// Print the value of each view field.
foreach (string fieldName in viewFields)
{
Console.WriteLine("{0} = {1}", fieldName, item[fieldName]);
}
Console.WriteLine();
}
}
}
Console.ReadLine();
}
}
}
Vea también
Referencia
Espacio de nombres Microsoft.SharePoint
GetItems(String, [])