diff --git a/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index.sln b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index.sln new file mode 100644 index 000000000..e7724eef9 --- /dev/null +++ b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Get-form-field-by-its-name-and-index", "Get-form-field-by-its-name-and-index\Get-form-field-by-its-name-and-index.csproj", "{D3AF529E-DB54-4294-A876-DD42E1E472D0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3AF529E-DB54-4294-A876-DD42E1E472D0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58137FF9-5AE1-4514-9929-3A8A7DA1DFEB} + EndGlobalSection +EndGlobal diff --git a/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Data/Template.docx b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Data/Template.docx new file mode 100644 index 000000000..6fb6570ea Binary files /dev/null and b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Data/Template.docx differ diff --git a/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Get-form-field-by-its-name-and-index.csproj b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Get-form-field-by-its-name-and-index.csproj new file mode 100644 index 000000000..bfd26860f --- /dev/null +++ b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Get-form-field-by-its-name-and-index.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Get_form_field_by_its_name_and_index + + + + + + + + + Always + + + Always + + + + diff --git a/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Output/.gitkeep b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Program.cs b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Program.cs new file mode 100644 index 000000000..26cb73f52 --- /dev/null +++ b/Form-Fields/Get-form-field-by-its-name-and-index/.NET/Get-form-field-by-its-name-and-index/Program.cs @@ -0,0 +1,47 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; + +//Loads an existing Word document into DocIO instance. +WordDocument document = new WordDocument(@"../../../Data/Template.docx"); +IWSection sec = document.LastSection; +WTextFormField textFF; +WDropDownFormField dropFF; + +//Access the form field with field name +textFF = sec.Body.FormFields["FullName"] as WTextFormField; + +//Fill value for the textfield +textFF.TextRange.Text = "John"; + +//Access the form field with field name +textFF = sec.Body.FormFields["BirthDayField"] as WTextFormField; +textFF.TextRange.Text = "5.13.1980"; + +//Access the form field with index +textFF = sec.Body.FormFields[2] as WTextFormField; +textFF.TextRange.Text = "221b Baker Street"; + +textFF = sec.Body.FormFields[3] as WTextFormField; +textFF.TextRange.Text = "(206)555-3412"; + +textFF = sec.Body.FormFields[4] as WTextFormField; +textFF.TextRange.Text = "John@company.com"; + +dropFF = sec.Body.FormFields[5] as WDropDownFormField; + +//Set the value +dropFF.DropDownSelectedIndex = 1; + +textFF = sec.Body.FormFields[6] as WTextFormField; +textFF.TextRange.Text = "Michigan University"; + +dropFF = sec.Body.FormFields[7] as WDropDownFormField; +dropFF.DropDownSelectedIndex = 1; + +dropFF = sec.Body.FormFields[8] as WDropDownFormField; +dropFF.DropDownSelectedIndex = 2; + +//Saving the document as .docx +document.Save(@"../../../Output/Sample.docx", FormatType.Docx); +//Closes the document instance. +document.Close(); \ No newline at end of file