如何根据SharePoint列表的索引而不是字段名称在Windows窗体列表中添加SharePoint SPList项?
答案 0 :(得分:0)
完全未经测试,在喝早晨咖啡时新鲜。祝你好运!
var list = siteWeb.Lists.TryGetList(listName);
if (list == null)
{
return;
}
var items = list.GetItems(query);
var countOfItems = items.Count;
if (countOfItems == 0)
{
return;
}
var listItemFieldObjects = items.Cast<SPListItem>().Select(item => item[1]);
foreach (var item in listItemFieldObjects)
{
var listViewItem = new ListViewItem("Object's value");
listView.BeginUpdate();
listViewItem.SubItems.Add(item.ToString());
listView.Items.Add(listViewItem);
listView.EndUpdate();
}