Get form field name on click
I've added this:
private void pdfViewerMappings_FormFieldClicked(object sender, FormFieldClickedEventArgs args)
but I can't figure out how to get the name of the field that was clicked on.
In the WPF PdfViewer, you can retrieve the form field name by typecasting the FormField property of the FormFieldClickedEventArgs to the respective control. We have attached a sample and a code snippet demonstrating how to retrieve the name for all supported form fields using the FormFieldClicked event of PdfViewerControl.
UG link: https://help.syncfusion.com/wpf/pdf-viewer/form-filling-in-pdf#retrieve-the-form-field-details
|
private void PdfViewerControl_FormFieldClicked(object sender, Syncfusion.Windows.PdfViewer.FormFieldClickedEventArgs args) { if (args.FormField is TextBox) { //Typecast the `FormField` property to `System.Windows.Controls.TextBox` TextBox text = args.FormField as TextBox; String name = text.Name; } else if (args.FormField is PasswordBox) { //Typecast the `FormField` property to `System.Windows.Controls.PasswordBox` PasswordBox PasstextBox = args.FormField as PasswordBox; String name = PasstextBox.Name; } else if (args.FormField is ListBox) { //Typecast the `FormField` property to `System.Windows.Controls.ListBox` ListBox listBox = args.FormField as ListBox; String name = listBox.Name; } else if (args.FormField is ComboBox) { //Typecast the `FormField` property to `System.Windows.Controls.ComboBox` ComboBox comboBox = args.FormField as ComboBox; String name = comboBox.Name; } else if (args.FormField is CheckBox) { //Typecast the `FormField` property to `System.Windows.Controls.CheckBox` CheckBox checkBox = args.FormField as CheckBox; String name = checkBox.Name; } else if (args.FormField is RadioButton) { //Typecast the `FormField` property to `System.Windows.Controls.RadioButton` RadioButton radiobtn = args.FormField as RadioButton; String name = radiobtn.Name; } } |
Attachment: PdfViewerWPF_79fe144.zip
Awesome! Thanks so much.
Most welcome, please get back to us for any further assistance.
- 3 Replies
- 2 Participants
- Marked answer
-
KA Keith A Price
- Feb 10, 2024 07:50 PM UTC
- Feb 13, 2024 06:49 AM UTC