Q:
在新建一个task item的Assigned To字段默认只能选择一个人,或者一个组,
但是这里如果我想选择2个人或者2个以上,则不行,需要去Team Site > Tasks > Settings > Edit Column 把 Allow multiple selections 选择Yes
如何用代码实现: Allow multiple selections 选项为 Yes , 默认为 No
A:
using (SPSite site = new SPSite("http://moss:5000")) using (SPWeb web = site.RootWeb) { web.AllowUnsafeUpdates = true; SPList list = web.Lists["Tasks"]; SPFieldLookup userField = list.Fields["Assigned To"] as SPFieldLookup; userField.AllowMultipleValues = true; userField.Update(); }
谢谢: Justin Liu 给我提供的解决方案!
另:
Microsoft.SharePoint.SPField 的派生类:
Microsoft.SharePoint.SPFieldAttachments
Microsoft.SharePoint.SPFieldBoolean
Microsoft.SharePoint.SPFieldCalculated
Microsoft.SharePoint.SPFieldComputed
Microsoft.SharePoint.SPFieldCrossProjectLink
Microsoft.SharePoint.SPFieldDateTime
Microsoft.SharePoint.SPFieldFile
Microsoft.SharePoint.SPFieldLookup
Microsoft.SharePoint.SPFieldMultiChoice
Microsoft.SharePoint.SPFieldMultiColumn
Microsoft.SharePoint.SPFieldMultiLineText
Microsoft.SharePoint.SPFieldNumber
Microsoft.SharePoint.SPFieldPageSeparator
Microsoft.SharePoint.SPFieldRecurrence
Microsoft.SharePoint.SPFieldText
Microsoft.SharePoint.SPFieldUrl