GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetFormFieldBorderColor Method / GetFormFieldBorderColor(Int32,Int32) 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.
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
GetFormFieldBorderColor(Int32,Int32) Method
In This Topic
Returns the border color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group can have its own border color defined. As said, this method is only applicable to radio buttons.

The method only returns the correct form field's border color if this attribute is specified in the form field object itself, otherwise it will fail. The form field's border color attribute is not assigned automatically when creating the form field, however, you can specify the border color using the SetFormFieldBorderColor(Int32,Int32,GdPictureColor) method right after adding the required form field on the page. Otherwise, the form field may display invisible.

Syntax
'Declaration
 
Public Overloads Function GetFormFieldBorderColor( _
   ByVal FieldId As Integer, _
   ByVal ChildIdx As Integer _
) As GdPictureColor
public GdPictureColor GetFormFieldBorderColor( 
   int FieldId,
   int ChildIdx
)
public function GetFormFieldBorderColor( 
    FieldId: Integer;
    ChildIdx: Integer
): GdPictureColor; 
public function GetFormFieldBorderColor( 
   FieldId : int,
   ChildIdx : int
) : GdPictureColor;
public: GdPictureColor GetFormFieldBorderColor( 
   int FieldId,
   int ChildIdx
) 
public:
GdPictureColor GetFormFieldBorderColor( 
   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

The border color of the specified form field, if defined. 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. At the same, this method is only meaningful for radio buttons, otherwise it will fail.

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 the form field's border color attribute is not assigned automatically when creating the form field. If this attribute is not specified, this method will fail.

Example
How to find out the the border color for radio button form fields.
Dim caption As String = "Example: GetFormFieldBorderColor"
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
        Dim message As String = ""
        Dim formID As Integer = 0
        Dim hasColor As Boolean = False, hasRB As Boolean = False
        Dim borderColor As Color = Color.Black
        Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
        For i As Integer = 0 To count - 1
            formID = gdpicturePDF.GetFormFieldId(i)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                type = gdpicturePDF.GetFormFieldType(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
                        hasRB = True
                        message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
                        hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            'The border color is the same (either undefined or specified) for all child radio buttons in this group.
                            message = message + " - borderColor: "
                            If hasColor Then
                                borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                    message = message + borderColor.ToString()
                                Else
                                    message = message + gdpicturePDF.GetStat().ToString()
                                End If
                            Else
                                message = message + " undefined"
                            End If
                        Else
                            If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
                                'The border color is different for the individual child radio buttons in this group.
                                message = message + " has a different border color for its child radio buttons."
                                Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                    For j As Integer = 0 To kids - 1
                                        message = message + vbCrLf + "  " + j.ToString() + ".child - border color: "
                                        hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j)
                                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                            If hasColor Then
                                                borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j)
                                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                                    message = message + borderColor.ToString()
                                                Else
                                                    message = message + gdpicturePDF.GetStat().ToString()
                                                End If
                                            Else
                                                message = message + "undefined"
                                            End If
                                        Else
                                            message = message + gdpicturePDF.GetStat().ToString()
                                        End If
                                    Next
                                Else
                                    message = message + vbCrLf + "  The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                                End If
                            Else
                                message = message + vbCrLf + "  The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                            End If
                        End If
                    End If
                Else
                    MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
                    Exit For
                End If
            Else
                MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
                Exit For
            End If
            message += vbCrLf
        Next
        If count = 0 Then
            message = "This file doesn't include forms."
        ElseIf Not hasRB Then
            message = "This file doesn't include radio button form fields."
        End If
        MessageBox.Show(message, caption)
    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: GetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string message = "";
        int formID = 0;
        bool hasColor = false, hasRB = false;
        Color borderColor = Color.Black;
        PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
        for (int i = 0; i < count; i++)
        {
            formID = gdpicturePDF.GetFormFieldId(i);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                type = gdpicturePDF.GetFormFieldType(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
                    {
                        hasRB = true;
                        message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
                        hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        {
                            //The border color is the same (either undefined or specified) for all child radio buttons in this group.
                            message = message + " - border color: ";
                            if (hasColor)
                            {
                                borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                    message = message + borderColor.ToString();
                                else
                                    message = message + gdpicturePDF.GetStat().ToString();
                            }
                            else message = message + " undefined";
                        }
                        else
                        {
                            if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
                            {
                                //The border color is different for the individual child radio buttons in this group.
                                message = message + " has a different border color for its child radio buttons.";
                                int kids = gdpicturePDF.GetFormFieldChildCount(formID);
                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                {
                                    for (int j = 0; j < kids; j++)
                                    {
                                        message = message + "\n  " + j.ToString() + ".child - border color: ";
                                        hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j);
                                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                        {
                                            if (hasColor)
                                            {
                                                borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j);
                                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                                    message = message + borderColor.ToString();
                                                else
                                                    message = message + gdpicturePDF.GetStat().ToString();
                                            }
                                            else message = message + "undefined";
                                        }
                                        else message = message + gdpicturePDF.GetStat().ToString();
                                    }
                                }
                                else message = message + "\n  The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
                            }
                            else message = message + "\n  The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
                    break;
                }
            }
            else
            {
                MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
                break;
            }
            message += "\n";
        }
        if (count == 0) message = "This file doesn't include forms.";
        else if (!hasRB) message = "This file doesn't include radio button form fields.";
        MessageBox.Show(message, 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