得到Radio Button值我做错了什么?

时间:2016-06-14 20:25:46

标签: vb.net itextsharp

我正在使用PdfStamper从PDF表单中获取字段值。我可以使用Acrofields类中的GetField()函数成功地从文本框,组合框和复选框中获取值。但是当谈到Radio Buttons时,我要么得到集合中第一个单选按钮的值,要么“关闭”。我错过了什么?我应该以不同的方式获得价值吗?是否有一个我不知道的常见错误? 以下是我的代码示例:

Private Sub btnFinish_ItemClick2(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnFinish.ItemClick
Dim pdfReader As New PdfReader(savedfile)
    Dim pdfStamper As New PdfStamper(pdfReader, New FileStream(pdf_prefinal, FileMode.Create))
    Dim pdfFormFields As AcroFields = pdfStamper.AcroFields

    Dim pdfFieldscollection As System.Collections.Generic.IDictionary(Of String, iTextSharp.text.pdf.AcroFields.Item) = pdfReader.AcroFields.Fields
    Dim dsNewRow As DataRow = DualReview_databaseDataSet.tblEngineeringReviewTracking.NewRow()

    Dim rqdEmptyFields As New List(Of String)
    Dim rqdCommentFields As New List(Of Integer)
    Dim keepSavingfields As Boolean = True

    'Loop through each field in order to find empty fields and to save fields value
    For Each field In pdfFieldscollection

        Dim fieldName As String = field.Key
        Dim fieldType As Integer = pdfFormFields.GetFieldType(fieldName)
        Dim fieldValue As String = pdfFormFields.GetField(fieldName)
        Dim saveCurrentField As Boolean = False
        '...

    Next
End Sub

1 个答案:

答案 0 :(得分:1)

同一“组”中的所有单选按钮应具有相同的名称。每个按钮都应该有自己的“导出值”。在您的代码中,Name将使用所选按钮的值返回一次。 (“出口价值”属性应仅命名为“价值”IMO。)