How to obtain checkbox current value, and appearance states?

Q:

I'm trying to make AcroForms interactive. For editboxes, I can place a
regular windows editbox over the view and pass it's value when the
control looses focus, but for checkboxes I wanted to detect a click and
change the value. I did a Field.SetValue( new Name("Yes") ) as I found
in a sample, but the checkbox always gets cleared. Is there another
value I should use? I tried 1 and 0 and those values seem to work. What
I'd like is a list of possible values
---

A:

The choice between the checked and unchecked appearance states is
determined by the AS entry in the annotation dictionary.

So when you modify the chackbox value using Field.SetValue( new
Name("Yes") ) you also need to update AS entry to point to the new
appearance. Alternatively you can call field.RefreshAppearance() and
PDFNet will do this for you.

The appearance for the off state is optional but, if present, must be
stored in the appearance dictionary under the name 'Off'. The
recommended (but not required) name for the on state is 'Yes'.

What I'd like is a list of possible values

You could use the following code:

Annot ann(field.GetSDFObj());
Obj* cur_appearance = Ann.GetAppearance();

And to list all possible values:

Obj* fd = field.GetSDFObj()
try
{
  Obj* appearances_dict = fd->Get("AP")->second->Get("N")->second;
  DictIterator itr = appearances_dict->DictBegin();
  DictIterator end = appearances_dict->DictEnd();
  for(; itr!=end; ++itr) {
    cout << itr->first->GetName();
    // itr->second is the appearance stream
  }
} catch(...) {}