A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GetFormFieldId, GetFormFieldChildID or methods intended to add form fields.
A string representation of the new current value of the specified form field.
A string separator, that is used to delimit the item names in the Value parameter. This parameter is meaningful only for list boxes allowing multiple selections.
Example





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

SetFormFieldValue(Int32,String,String) Method

In This Topic
Sets the current value of a required form field, here a list box, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. This method is intended to be used for list boxes, which allow multiple selections. The names of the individual items need to be delimited in the specified Value parameter with the defined Separator parameter. The items represented by its names, which are included in the Value, are subsequently selected in the required list box as its current value.
Syntax
'Declaration
 
Public Overloads Function SetFormFieldValue( _
   ByVal FieldId As Integer, _
   ByVal Value As String, _
   ByVal Separator As String _
) As GdPictureStatus
public GdPictureStatus SetFormFieldValue( 
   int FieldId,
   string Value,
   string Separator
)
public function SetFormFieldValue( 
    FieldId: Integer;
    Value: String;
    Separator: String
): GdPictureStatus; 
public function SetFormFieldValue( 
   FieldId : int,
   Value : String,
   Separator : String
) : GdPictureStatus;
public: GdPictureStatus SetFormFieldValue( 
   int FieldId,
   string* Value,
   string* Separator
) 
public:
GdPictureStatus SetFormFieldValue( 
   int FieldId,
   String^ Value,
   String^ Separator
) 

Parameters

FieldId
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods like GetFormFieldId, GetFormFieldChildID or methods intended to add form fields.
Value
A string representation of the new current value of the specified form field.
Separator
A string separator, that is used to delimit the item names in the Value parameter. This parameter is meaningful only for list boxes allowing multiple selections.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Just to remind you, that this method is only meaningful for list boxes that allow multiple selections, otherwise, the Separator parameter is not taking into account.

Example
How to set multiple selections into a list box that supports this feature.
Dim caption As String = "Example: SetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the AddFormFieldItem(Integer, String, String) method.
If gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
        Dim formID As Integer = 0
        Dim value As String = ""
        Dim isMulti 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
                'Getting the form field's type.
                type = gdpicturePDF.GetFormFieldType(formID)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    If type = PdfFormFieldType.PdfFormFieldTypeList Then
                        'Getting the form field's current value.
                        message = message + "  current value: "
                        value = gdpicturePDF.GetFormFieldValue(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            message = message + value
                        Else
                            message = message + gdpicturePDF.GetStat().ToString()
                        End If
                        message += vbCrLf
                        'Setting the form field's new current value.
                        isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID)
                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                            If isMulti Then
                                value = "German,French"
                                If gdpicturePDF.SetFormFieldValue(formID, value, ",") = GdPictureStatus.OK Then
                                    value = gdpicturePDF.GetFormFieldValue(formID, ";")
                                    message = message + "  new value: "
                                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                        message = message + value
                                    Else
                                        message = message + gdpicturePDF.GetStat().ToString()
                                    End If
                                    message += vbCrLf
                                Else
                                    message = message + "  setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
                                End If
                            Else
                                value = "French"
                                If gdpicturePDF.SetFormFieldValue(formID, value) = GdPictureStatus.OK Then
                                    value = gdpicturePDF.GetFormFieldValue(formID)
                                    message = message + "  new value: "
                                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                        message = message + value
                                    Else
                                        message = message + gdpicturePDF.GetStat().ToString()
                                    End If
                                    message += vbCrLf
                                Else
                                    message = message + "  setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
                                End If
                            End If
                        Else
                            message = message + "  multiselection: " + gdpicturePDF.GetStat().ToString() + vbCrLf
                        End If
                    End If
                Else
                    message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                    Exit For
                End If
            Else
                message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
                Exit For
            End If
        Next
        If gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") = GdPictureStatus.OK Then
            message = message + vbCrLf + "The file has been saved successfully."
        Else
            message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
        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: SetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the AddFormFieldItem(Int, String, String) method.
if (gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetFormFieldsCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string message = "This document contains " + count.ToString() + " form fields.\n";
        int formID = 0;
        string value = "";
        bool isMulti = false;
        PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
        for (int i = 0; i < count; i++)
        {
            formID = gdpicturePDF.GetFormFieldId(i);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                //Getting the form field's type.
                type = gdpicturePDF.GetFormFieldType(formID);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    if (type == PdfFormFieldType.PdfFormFieldTypeList)
                    {
                        //Getting the form field's current value.
                        message = message + "  current value: ";
                        value = gdpicturePDF.GetFormFieldValue(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                            message = message + value;
                        else
                            message = message + gdpicturePDF.GetStat().ToString();
                        message += "\n";
            
                        //Setting the form field's new current value.
                        isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID);
                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                        {
                            if (isMulti)
                            {
                                value = "German,French";
                                if (gdpicturePDF.SetFormFieldValue(formID, value, ",") == GdPictureStatus.OK)
                                {
                                    value = gdpicturePDF.GetFormFieldValue(formID, ";");
                                    message = message + "  new value: ";
                                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                        message = message + value;
                                    else
                                        message = message + gdpicturePDF.GetStat().ToString();
                                    message += "\n";
                                }
                                else
                                    message = message + "  setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
                            }
                            else
                            {
                                value = "French";
                                if (gdpicturePDF.SetFormFieldValue(formID, value) == GdPictureStatus.OK)
                                {
                                    value = gdpicturePDF.GetFormFieldValue(formID);
                                    message = message + "  new value: ";
                                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                        message = message + value;
                                    else
                                        message = message + gdpicturePDF.GetStat().ToString();
                                    message += "\n";
                                }
                                else
                                    message = message + "  setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
                            }
                        }
                        else
                            message = message + "  multiselection: " + gdpicturePDF.GetStat().ToString() + "\n";
                    }
                }
                else
                {
                    message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
                    break;
                }
            }
            else
            {
                message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
                break;
            }
        }
        if (gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") == GdPictureStatus.OK)
            message = message + "\nThe file has been saved successfully.";
        else
            message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
        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