- Home
- Forum
- Xamarin.Forms
- Checking checkbox using bookmark
Checking checkbox using bookmark
Hello,
I'm trying to checking checkbox inside a word document using bookmark to get to the checkbox.
Only checkbox form field (legacy) are recognized, but i could got them with bookmark. I change the checked status and save. Opening the word, checkbox are unchecked. I can change text and add image using bookmark, but for checkbox i don't find how to do it.
In fact, i can have checked box if i delete the bookmark content and add a new checkbox, but i'm also loosing formatting.
My code :
internal void Checkbox(BookmarksNavigator bookmarkNavigator, string BookName)
{
bookmarkNavigator.MoveToBookmark(BookName);
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
var body = part.BodyItems[0] as WParagraph;
var item = body.ChildEntities.FirstItem;
var check = item as WCheckBox;
check.Checked = true;
//// I tried theses command too
//check.CalculateOnExit = true;
//check.Update();
}
After i save the stream and open the doc.
Thank you for contacting Syncfusion support.
From the given details we have found that your requirement is to check the check box using bookmark Navigator. We have prepared the sample application to achieve your requirement. Please find the sample from the below link.
https://www.syncfusion.com/downloads/support/forum/168999/ze/ConsoleCoreSample-703528298.zip
In the above sample we have done the following things.
1. Loaded the input template document.
3. After modified the check box status, replace the TextBodyPart using bookmark navigator to get reflect the changes in the DOM level of word document.
Please refer the UG documentation link given below.
https://help.syncfusion.com/file-formats/docio/working-with-form-fields#check-box
Regards,
Thank this indeed working !
Although, it's erase content after the checkbox.
In this lighty modified word document, content after checkbox are erased, even other checkbox with another bookmark.
Thank you for your update.
We have tried to reproduce the reported issue content after checkbox are erased, but the issue has not reproduced at our end. So could you please share us the input Word document, simple sample application which reproduce the issue and screenshot of the issue. This will be more helpful for us to replicate the same problems at our end. Thereby, we will proceed further and share the appropriate solution at the earliest.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same.
Regards,
Thank you for your update.
If your requirement is to check the checkbox for a particular named bookmark means, then you can iterate the paragraph items has checkbox and check the checkbox based on the particular bookmark name. We have prepared the sample application to achieve your requirement. Please find the sample from the below link.
https://www.syncfusion.com/downloads/support/forum/168999/ze/ConsoleCoreSample-1080216764.zip
In the above sample we have done the following things.
1. Loaded the input template document.
3. Saves the Word document.
Regards,
It's working perfectly.
Thank you for your excellent support.
- 7 Replies
- 2 Participants
- Marked answer
-
GR gregory
- Sep 20, 2021 09:05 PM UTC
- Sep 27, 2021 08:04 AM UTC