Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Oct 05, 2016 10:26 am

Currently I am looping through all sections and formfields to find a particular one and change its value. Is there a way to jump directly to it much like the ability with bookmarks?

foreach (var sec in doc.Sections.Cast<Section>())
{
foreach (Spire.Doc.Fields.FormField ff in sec.Body.FormFields)
{
if (ff.Name == "Benefit66Yes")
{
var cb = ff as CheckBoxFormField;
cb.Checked = true;
yesfound = true;
}
if (ff.Name == "Benefit66No")
{
var cb = ff as CheckBoxFormField;
cb.Checked = false;
nofound = true;
}
if (yesfound && nofound)
break;
}
if (yesfound && nofound)
break;
}

with bookmarks, we can jump directly to it:
var bookmark = doc.Bookmarks.FindByName(bookmarkName);

nseyler
 
Posts: 12
Joined: Wed Nov 04, 2015 6:43 pm

Thu Oct 06, 2016 2:41 am

Hello,

Thanks for your inquiry. Sorry that I am afraid that now there is no the method to go directly to formfield without searching.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Oct 18, 2016 9:03 am

Hello,

Now the collection of Fields on the Document object has been public, you could download the newest hotfix(Spire.Doc Pack(hot fix) Version:5.7.126) and go directly to FormField via the following way.
Code: Select all
doc.Fields[int index]


Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc

cron