GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldRadioInUnison Method
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.
Example





In This Topic
GetFormFieldRadioInUnison Method (GdPicturePDF)
In This Topic
Returns, if the RadiosInUnison flag of a required form field, here a radio button, is set. The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to radio button fields, so this method is explicitly applicable to radio button form field objects.

If this flag is set, a group of radio buttons within a radio button field that use the same value for the On state will turn on and off in unison; that is if one is checked, they are all checked. If this flag is not set, the buttons are mutually exclusive.

Syntax
'Declaration
 
Public Function GetFormFieldRadioInUnison( _
   ByVal FieldId As Integer _
) As Boolean
public bool GetFormFieldRadioInUnison( 
   int FieldId
)
public function GetFormFieldRadioInUnison( 
    FieldId: Integer
): Boolean; 
public function GetFormFieldRadioInUnison( 
   FieldId : int
) : boolean;
public: bool GetFormFieldRadioInUnison( 
   int FieldId
) 
public:
bool GetFormFieldRadioInUnison( 
   int FieldId
) 

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.

Return Value

true if the RadiosInUnison flag of the specified radio button is set, otherwise false. 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. Be aware that the same value of this flag is assigned to all child radio buttons in a group.

Example
How to determine, if the RadiosInUnison flag is set and how to subsequently deselect this flag for all radio buttons in the current document.
Dim caption As String = "Example: GetFormFieldRadioInUnison"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If count = 0 Then
            MessageBox.Show("This document does not contain any forms.", caption)
        Else
            Dim title As String = ""
            Dim formID As Integer = 0
            Dim isUnison As Boolean = False, save As Boolean = False
            Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
            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
                    title = gdpicturePDF.GetFormFieldTitle(formID)
                    If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                    isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID)
                    If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
                    If isUnison Then
                        If gdpicturePDF.SetFormFieldRadioInUnison(formID, False) <> GdPictureStatus.OK Then Exit For
                        save = True
                    End If
                End If
            Next
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                If save Then
                    If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
                        MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
                    Else
                        MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
                    End If
                Else
                    MessageBox.Show("This document does not contain any radio buttons.", caption)
                End If
            Else
                MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        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: GetFormFieldRadioInUnison";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if (count == 0)
            MessageBox.Show("This document does not contain any forms.", caption);
        else
        {
            string title = "";
            int formID = 0;
            bool isUnison = false, save = false;
            PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
            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)
                {
                    title = gdpicturePDF.GetFormFieldTitle(formID);
                    if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
            
                    isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID);
                    if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
            
                    if (isUnison)
                    {
                        if (gdpicturePDF.SetFormFieldRadioInUnison(formID, false) != GdPictureStatus.OK) break;
                        save = true;
                    }
                }
            }
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                if (save)
                {
                    if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
                        MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
                    else
                        MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
                }
                else
                    MessageBox.Show("This document does not contain any radio buttons.", caption);
            }
            else
                MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), 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