PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

PdfComboBoxField-Set selected element by value instead index
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4016
Page 1 of 1

Author:  rbenhamouda [ Fri Sep 13, 2019 9:08 pm ]
Post subject:  PdfComboBoxField-Set selected element by value instead index

Hi,

Using PDFSharp 1.50.5147.0:

1. Is there a way to fill a pdf form field (type: PdfComboBoxField) using text value instead index.
and allow to add it if it doesn't exist?

2. Is it possible to retrieve PdfComboBoxField value (or any other fields type that can have validation values)? If yes how?

Thanks

Author:  rbenhamouda [ Tue Sep 17, 2019 1:51 pm ]
Post subject:  Re: PdfComboBoxField-Set selected element by value instead i

I found a solution for my case, maybe it's not elegant, but it did the trick: (PDFSharp V. 1.50.5147.0)

Here is the solution:

Code:
PdfComboBoxField cbxField;
if ((cbxField = field as PdfComboBoxField) != null)
{
   cbxField.Value = new PdfString("( )");
   cbxField.Value = new PdfString(MyValue);  //MyValue is not required to be in the combobox choice list
}

//Notes:
// cbxField.Value = new PdfString("(" + MyValue + ")");  //MyValue must be in the combobox and it will be displayed with the parentheses in the pdf form.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/