Skip to content

Commit dcde7e4

Browse files
Add sample for add check box content control
1 parent 1ffe70f commit dcde7e4

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35417.141 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-tick-mark-checkbox", "Add-tick-mark-checkbox\Add-tick-mark-checkbox.csproj", "{DDE6F50A-B79C-422F-80D3-21249A81D1EC}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{DDE6F50A-B79C-422F-80D3-21249A81D1EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DDE6F50A-B79C-422F-80D3-21249A81D1EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DDE6F50A-B79C-422F-80D3-21249A81D1EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DDE6F50A-B79C-422F-80D3-21249A81D1EC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_tick_mark_checkbox</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Output\.gitkeep">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
21+
22+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
//Register Syncfusion license
5+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mgo+DSMBMAY9C3t2UlhhQlNHfV5DQmBWfFN0QXNYfVRwdF9GYEwgOX1dQl9nSXZTc0VlWndfcXNSQWc=");
6+
7+
using (WordDocument wordDocument = new WordDocument())
8+
{
9+
// Add a section & a paragraph in the empty document
10+
wordDocument.EnsureMinimal();
11+
// Append an inline content control for the tick checkbox
12+
IInlineContentControl tickInline = wordDocument.LastParagraph.AppendInlineContentControl(ContentControlType.CheckBox);
13+
// Create a CheckBoxState for the tick symbol
14+
CheckBoxState tickState = new CheckBoxState
15+
{
16+
Font = "Wingdings",
17+
Value = "\uF0FE" // Unicode for tick symbol (✓) in Wingdings
18+
};
19+
// Set the checked state of the tick checkbox content control
20+
tickInline.ContentControlProperties.CheckedState = tickState;
21+
// Create a CheckBoxState for the unchecked state (empty box)
22+
CheckBoxState uncheckedState = new CheckBoxState
23+
{
24+
Font = "Wingdings",
25+
Value = "\uF0A8" // Unicode for empty box in Wingdings
26+
};
27+
// Set the unchecked state of the tick checkbox content control
28+
tickInline.ContentControlProperties.UncheckedState = uncheckedState;
29+
// Set the initial state of the tick checkbox as checked
30+
tickInline.ContentControlProperties.IsChecked = true;
31+
using (FileStream outputStream1 = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite))
32+
{
33+
wordDocument.Save(outputStream1, FormatType.Docx);
34+
}
35+
}

0 commit comments

Comments
 (0)