How to add a People Picker SPField to a SPList in SharePoint?
Looking for a snippet of code开发者_如何学编程.
The "People picker" control is used by SP when a column is of type User
so, the following snippet will add one such column:
using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["MySite"])
{
SPFieldCollection collFields = oWebsite.Lists["MyList"].Fields;
collFields.Add("MyField", Microsoft.SharePoint.SPFieldType.User, false);
}
精彩评论