Set specific radiobutton value


I have a radio button group (called "GroupGender") with 3 radio buttons :

- Male
- Female
- Unspecified

How can i set the value for the second value (for example) ?

I've tried

Field f = document.GetField("GroupGender");

Is there a way to specify the index / specific option name here ?


The following should work, but only if “Female” matches one of the appearance states. It might be something else like “Option1”.

Field f = document.GetField("GroupGender");

To query the appearance states, use the following code.

static string GetOnState(Field field)
Widget widget = new Widget(field.GetSDFObj());
Obj normal_app_dict = null;
Obj widget_object = widget.GetSDFObj();
Obj appearances_dict = widget_object.FindObj("AP");
if (appearances_dict != null) normal_app_dict = appearances_dict.FindObj("N");
if (normal_app_dict != null && normal_app_dict.IsDict())
for (DictIterator itr = normal_app_dict.GetDictIterator(); itr.HasNext(); itr.Next())
Obj key = itr.Key();
if (key != null && key.IsName())
string key_name = key.GetName();
if(String.Compare(key_name, "off", true) != 0)
return key_name;
throw new Exception("Error getting on value for field");

Generally each radio button will have two states. “Off” and then the on value, such as “Female”.