How do you print combo box item lists values?

I am trying list all the item values present in a combo box. I am able
to find the field using
Field fieldObj = PDFDocument.GetField("fieldname");

How do I get item values or text from this field object?

In case of combo or list bof field (i.e. e_choice), field.GetValue()
returns the item or items currently selected in the choice field. If
the field does not allow multiple selection—that is, if the
MultiSelect flag is not set or if multiple selection is supported but
only one item is currently selected, the return value is a text string
object representing the name
of the selected item. If multiple items are selected, GetValue()
returns an array object of such strings.

The following code snippet (in C#) shows how to print selected values:

Field f = itr.Current();
if (f.GetType() == Field.Type.e_choice) {
  Console.WriteLine("Field name: {0}", f.GetName());
  Obj val = f.GetValue();
  if (val != null && val.IsNull()) {
  if (val.IsString()) {
    Console.WriteLine("Value: {0}", val.GetAsPDFText());
  }
  else if (val.IsArray()) {
    Obj obj;
    for (int i=0; i<val.Size(); ++i)
    {
      obj = val.GetAt(i);
      if (obj.IsString()) {
        Console.WriteLine("Value: {0}", val.GetAsPDFText());
      }
    }
  }
  }
}

If you need a really quick to obtain field values you could simple
call field.GetValueAsString().

Thanks for the reply.
But I need a way to get all the items, both select and non-selected
items.

Is it possible to get both selected and unselected items from the
field e_choice?

Thank you.

You can extract all possible values for a combo-box or a list-box by
iterating over all values stored in "Opt" array. For example:

// C# pseudocode:

// Find the root node for the field (in case the value is shared among
multiple fileds).
Obj node = field.GetSDFObj();
while( node.FindObj("T") != null) node = node.Get("Parent").Value();

// Get the Opt (i.e. Option) array
Obj opt = node.FindObj( "Opt" );
if(opt != null || opt.IsArray())
{
  for (int i=0; i<opt.Size(); ++i) {
    Obj option = opt.GetAt(i);
    if( option.IsString() ) {
       Console.WriteLine("{0:s}", option.GetAsPDFText());
    }
    else if( option.IsArray() && (option.Size() > 1) ) {
  option = option.GetAt(1);
  if( option.IsString() ) {
         Console.WriteLine("{0:s}", option.GetAsPDFText());
       }
     }
  }
}