'iText7: Setting radio button value is not working as expected

I have a PDF document created in InDesign with radio button group. Each choice has its own value.

PdfFormField field = AcroForm.GetField(fieldName);
field.SetValue(valueToSet);

Setting the choice's value assigned in InDesign doesn't work. No choice will be selected. It only works if I enter string number like "0" or "1", but not the actual value. I want to set the value with the choice's value. I do not want to use the "index" of the choice.

field.GetAppearanceStates();

If I return all the states I can see all the choice values, their indexes and the off state. What am I doing wrong? How can I assign the value with the choice's value with c# iText7? Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source