This thread might be a little stale but this could help someone else. Here is what I'm doing:
public static SPFieldChoice Create_Choice(SPFieldCollection spFieldCollection, string staticName, string displayName, string description, string[] choices, bool allowFillInChoices, bool required)
{
//Declarations
SPFieldChoice spFieldChoice;
string fieldSchema;
string choiceElements = string.Empty;
int choiceIndexOfStart;
int choiceIndexOfEnd;
//Create field.
if (spFieldCollection.TryGetFieldByStaticName(staticName) == null)
{ spFieldCollection.Add(spFieldCollection.CreateNewField(SPFieldType.Choice.ToString(), staticName));
}
spFieldChoice = (SPFieldChoice)spFieldCollection.TryGetFieldByStaticName(staticName);
spFieldChoice.Title = displayName;
spFieldChoice.StaticName = staticName;
spFieldChoice.Description = description;
spFieldChoice.Required = required;
spFieldChoice.FillInChoice = allowFillInChoices;
spFieldChoice.Update();
//Add choices.
//--------------
//Note: There is a bug in the SP object model when adding choices through a Sandbox solution. The logical way of
//adding choices does not work. Below is a workaround which adds choices through the SchemaXml directly. The Update() method
//is not called after making these changes.
//See the following for more information: http://sharepoint.stackexchange.com/questions/29519/add-choice-to-spfieldchoice-from-an-eventreceiver-in-sandboxed
//--------------
//Build choice xml element.
foreach (string choice in choices)
{ choiceElements += "<CHOICE>" + choice + "</CHOICE>";
}
//Update field schema.
fieldSchema = spFieldChoice.SchemaXml;
choiceIndexOfStart = fieldSchema.IndexOf("<CHOICES>");
if (choiceIndexOfStart >= 0)
{ choiceIndexOfEnd = fieldSchema.IndexOf("</CHOICES>");
fieldSchema = fieldSchema.Remove(choiceIndexOfStart, choiceIndexOfEnd - choiceIndexOfStart);
fieldSchema = fieldSchema.Replace("</CHOICES>", "<CHOICES>" + choiceElements + "</CHOICES>");
}
else
{ fieldSchema = fieldSchema.Replace("<CHOICES/>", "<CHOICES>" + choiceElements + "</CHOICES>");
}
spFieldChoice.SchemaXml = fieldSchema;
return spFieldChoice;
}