A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: GdPicturePDF.AddRadioButtonFormField, GdPicturePDF.GetFormFieldId or GdPicturePDF.GetFormFieldChildID.
The index of the required child radio button in a group. It must be a value from 0 to GdPicturePDF.GetFormFieldChildCount-1.

It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.

Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldOnStateName Method / GetFormFieldOnStateName(Int32,Int32) Method

GetFormFieldOnStateName(Int32,Int32) Method

In This Topic
Returns the string representation of the normal appearance (the On state) of a required form field, here a child radio button in a group, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a radio button and it is used when a radio button is not interacting with the user and for printing. As said, this method is only applicable to radio buttons.

If this attribute is not defined for the specified child radio button, then the resulting value for the On state is "On" by default.

Syntax
'Declaration
 
Public Overloads Function GetFormFieldOnStateName( _
   ByVal FieldId As Integer, _
   ByVal ChildIdx As Integer _
) As String
public string GetFormFieldOnStateName( 
   int FieldId,
   int ChildIdx
)
public function GetFormFieldOnStateName( 
    FieldId: Integer;
    ChildIdx: Integer
): String; 
public function GetFormFieldOnStateName( 
   FieldId : int,
   ChildIdx : int
) : String;
public: string* GetFormFieldOnStateName( 
   int FieldId,
   int ChildIdx
) 
public:
String^ GetFormFieldOnStateName( 
   int FieldId,
   int ChildIdx
) 

Parameters

FieldId
A unique form field identifier specifying a required form field object. You can obtain this identifier using these methods: GdPicturePDF.AddRadioButtonFormField, GdPicturePDF.GetFormFieldId or GdPicturePDF.GetFormFieldChildID.
ChildIdx
The index of the required child radio button in a group. It must be a value from 0 to GdPicturePDF.GetFormFieldChildCount-1.

It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.

Return Value

A string representation of the On state of the specified child radio button in a group. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail. If this attribute is undefined for the specified child radio button, then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".

Example
How to utilize the value representing the On state attribute of radio buttons.
Dim caption As String = "Example: GetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
If gdpicturePDF.LoadFromFile("test_radiobutton.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If count = 0 Then
            MessageBox.Show("This file doesn't include forms.", caption)
        Else
            Dim formID As Integer = 0
            Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
            Dim isChecked As Boolean = False, hasRadioButtons As Boolean = False
            Dim onName As String = "", userSelection As String = ""
            For i As Integer = 0 To count - 1
                formID = gdpicturePDF.GetFormFieldId(i)
                If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                Type = gdpicturePDF.GetFormFieldType(formID)
                If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                If Type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
                    hasRadioButtons = True
                    Dim rbCount As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
                    If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                    For j As Integer = 0 To rbCount - 1
                        isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
                        If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                        If isChecked Then
                            onName = gdpicturePDF.GetFormFieldOnStateName(formID, j)
                            If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                            userSelection = "They prefer " + onName + " colour."
                            Exit For 'Only one radio button is selected at a time.
                        End If
                    Next
                    Exit For
                End If
            Next
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                If Not hasRadioButtons Then
                    userSelection = "This file doesn't include radio buttons."
                Else
                    userSelection = "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString()
                End If
            End If
            MessageBox.Show(userSelection, caption)
        End If
    Else
        MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
if (gdpicturePDF.LoadFromFile(m_filename, false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if (count == 0)
            MessageBox.Show("This file doesn't include forms.", caption);
        else
        {
            int formID = 0;
            PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
            bool isChecked = false, hasRadioButtons = false;
            string onName = "", userSelection = "";
            for (int i = 0; i < count; i++)
            {
                formID = gdpicturePDF.GetFormFieldId(i);
                if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
                type = gdpicturePDF.GetFormFieldType(formID);
                if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
                if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
                {
                    hasRadioButtons = true;
                    int rbCount = gdpicturePDF.GetFormFieldChildCount(formID);
                    if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
                    for (int j = 0; j < rbCount; j++)
                    {
                        isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
                        if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
                        if (isChecked)
                        {
                            onName = gdpicturePDF.GetFormFieldOnStateName(formID, j);
                            if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
                            userSelection = "They prefer " + onName + " colour.";
                            break; //Only one radio button is selected at a time.
                        }
                    }
                    break;
                }
            }
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                if (!hasRadioButtons)
                    userSelection = "This file doesn't include radio buttons.";
            }
            else
                userSelection = "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString();
            MessageBox.Show(userSelection, caption);
        }
    }
    else
        MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also