SPFieldUserValueCollection
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
SPFieldUserValue Class
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Inheritance Hierarchy
SPFieldUserValue 继承自Microsoft.SharePoint.SPFieldLookupValue
所以有
LookupID:Gets or sets the ID of the lookup field;
LookupValue:Gets the value of the lookup field as a string.
本身有
User:Gets the user that is associated with the field value;
SipAddress:Gets the Session Initiation Protocol (SIP) address of the user.
下面是一段代码:收集 用户或用户组栏里面所有的用户和用户组。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
SPFieldUserValue Class
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Inheritance Hierarchy
所以有
LookupID:Gets or sets the ID of the lookup field;
LookupValue:Gets the value of the lookup field as a string.
本身有
User:Gets the user that is associated with the field value;
SipAddress:Gets the Session Initiation Protocol (SIP) address of the user.
下面是一段代码:收集 用户或用户组栏里面所有的用户和用户组。
List
<
SPUser
>
Users
=
new
List
<
SPUser
>
();
List < SPGroup > Groups = new List < SPGroup > ();
using (SPSite Site = new SPSite( " http://windbell " ))
{
SPWeb Web = Site.RootWeb;
SPList List = Web.Lists["测试列表"];
SPItem Item = List.Items[0];
SPFieldUserValueCollection Values = (SPFieldUserValueCollection)Item["用户和用户组"];
foreach (SPFieldUserValue Value in Values)
{
if (User != null)
{
SPUser User = Value.User;
Users.Add(User);
}
else
{
SPGroup Group = Web.Groups.GetByID(Value.LookupId);
Groups.Add(Group);
Users.AddRange(Group.Users);
}
}
}
List < SPGroup > Groups = new List < SPGroup > ();
using (SPSite Site = new SPSite( " http://windbell " ))
{
SPWeb Web = Site.RootWeb;
SPList List = Web.Lists["测试列表"];
SPItem Item = List.Items[0];
SPFieldUserValueCollection Values = (SPFieldUserValueCollection)Item["用户和用户组"];
foreach (SPFieldUserValue Value in Values)
{
if (User != null)
{
SPUser User = Value.User;
Users.Add(User);
}
else
{
SPGroup Group = Web.Groups.GetByID(Value.LookupId);
Groups.Add(Group);
Users.AddRange(Group.Users);
}
}
}