ADD SPFieldType.Choice, SPFieldChoice with SPChoiceFormatType.RadioButtons
using Microsoft.SharePoint;
using System.Collections.Specialized;
public void OnActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
string url = new Uri(web.Url).AbsolutePath;
SPDocumentLibrary docLib = (SPDocumentLibrary)web.GetListFromUrl("Shared Documents/Forms/AllItems.aspx");
// Create collection with choices.
StringCollection categories = new StringCollection();
categories.AddRange(new string [] {"Choice A", "Choice B", "Choice C"} );
// Create new field in the project documents list.
docLib.Fields.Add("MyNewField", SPFieldType.Choice, true, false, categories);
// Set additional settings of the new field.
SPFieldChoice fieldChoice = (SPFieldChoice)docLib.Fields["MyNewField"];
fieldChoice.DefaultValue = "Choice A";
fieldChoice.EditFormat = SPChoiceFormatType.RadioButtons;
// Save settings.
fieldChoice.Update();
docLib.Update();
}
Comments
Anonymous
May 03, 2010
Thank You Sir. This post really helped to resolve my issue. Regards, SriniAnonymous
October 16, 2011
The comment has been removed