Skip to content

Commit 927878f

Browse files
committed
update wrong code snippets and polish the existing docs
1 parent 6215e18 commit 927878f

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

knowledge-base/dynamic-docx-document-generation-radwordsprocessing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ ticketid: 1658864
1919

2020
This article demonstrates how to create tables and checkboxes within a DOCX document programmatically.
2121

22+
![DOCX with CheckBoxes](images/docx-with-checkboxes.png)
23+
2224
## Solution
2325

2426
To generate a DOCX document dynamically, including tables and checkboxes, follow these steps:
@@ -29,7 +31,7 @@ To generate a DOCX document dynamically, including tables and checkboxes, follow
2931
4. Customize the checkbox appearance and checked state.
3032
5. [Export the document]({%slug radwordsprocessing-formats-and-conversion-docx-docxformatprovider%}) as a DOCX file.
3133

32-
Here is a sample code snippet demonstrating how to accomplish this:
34+
Here is a sample code snippet demonstrating how to accomplish this:
3335

3436
```csharp
3537
static void Main(string[] args)
9.17 KB
Loading

libraries/radwordsprocessing/model/content-controls/content-controls.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,55 @@ The __CheckBox__ content control exposes two properties __CheckedState__ and __U
7878

7979
SdtCheckBoxState checkedBoxState = new SdtCheckBoxState();
8080
checkedBoxState.Font = new FontFamily("Arial");
81-
checkedBoxState.CharacterCode = 0040;
81+
checkedBoxState.CharacterCode = 0x0040;
8282

8383
SdtCheckBoxState uncheckedBoxState = new SdtCheckBoxState();
8484
uncheckedBoxState.Font = new FontFamily("Arial");
85-
uncheckedBoxState.CharacterCode = 0024;
85+
uncheckedBoxState.CharacterCode = 0x0024;
8686

8787
CheckBoxProperties properties = new CheckBoxProperties();
8888
properties.CheckedState = checkedBoxState;
8989
properties.UncheckedState = uncheckedBoxState;
9090
properties.Checked = true;
9191
{{endregion}}
9292

93+
The toggle states can be visualized with any characters specified in the properties. The following example demonstrates a complete code snippet how to insert toggled/untoggled checkboxes:
94+
95+
```csharp
96+
RadFlowDocument document = new RadFlowDocument();
97+
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
98+
99+
//define the characters which will visually indicate the toggle states
100+
SdtCheckBoxState checkedBoxState = new SdtCheckBoxState();
101+
checkedBoxState.Font = new FontFamily("Arial");
102+
checkedBoxState.CharacterCode = 0x0040;
103+
104+
SdtCheckBoxState uncheckedBoxState = new SdtCheckBoxState();
105+
uncheckedBoxState.Font = new FontFamily("Arial");
106+
uncheckedBoxState.CharacterCode = 0x0024;
107+
108+
CheckBoxProperties checkBoxProperties = new CheckBoxProperties();
109+
checkBoxProperties.CheckedState = checkedBoxState;
110+
checkBoxProperties.UncheckedState = uncheckedBoxState;
111+
checkBoxProperties.Checked = true;
112+
113+
Run checkedRun = editor.InsertText("Checked: ");
114+
editor.MoveToInlineEnd(checkedRun);
115+
SdtRangeStart sdt = editor.InsertStructuredDocumentTag(checkBoxProperties);
116+
editor.MoveToInlineEnd(sdt);
117+
Run runWithCheckBox = editor.InsertText(((char)checkBoxProperties.CheckedState.CharacterCode).ToString());
118+
runWithCheckBox.Properties.FontFamily.LocalValue = new ThemableFontFamily(checkBoxProperties.CheckedState.Font);
119+
editor.MoveToInlineEnd(sdt.End);
120+
121+
Run uncheckedRun = editor.InsertText(Environment.NewLine+ "UnChecked: ");
122+
editor.MoveToInlineEnd(uncheckedRun);
123+
sdt = editor.InsertStructuredDocumentTag(checkBoxProperties);
124+
editor.MoveToInlineEnd(sdt);
125+
runWithCheckBox = editor.InsertText(((char)checkBoxProperties.UncheckedState.CharacterCode).ToString());
126+
```
127+
128+
![Insert CheckBoxes](images/insert-checkboxes.gif)
129+
93130
### ComboBox and DropDownList
94131

95132
The __ComboBox__ and __DropDownList__ provide the user with options to choose from. The only difference is that when using ComboBox you can add a value that is not defined in the list.
@@ -169,5 +206,6 @@ The __Text__ content control allows you to enter plain text. The text content co
169206
# See Also
170207

171208
* [Working with Content Controls]({%slug wordsprocessing-model-working-with-content-controls%})
209+
* [Generating Dynamic DOCX Documents with Tables and CheckBoxes using RadWordsProcessing]({%slug dynamic-docx-document-generation-radwordsprocessing%})
172210

173211

65 KB
Loading

libraries/radwordsprocessing/model/table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,4 @@ __Example 5__ demonstrates how to add a __Table__ with 5 rows and 10 columns to
178178
* [TableRow]({%slug radwordsprocessing-model-tablerow%})
179179
* [TableCell]({%slug radwordsprocessing-model-tablecell%})
180180
* [Style Properties]({%slug radwordsprocessing-concepts-style-properties%})
181+
* [Generating Dynamic DOCX Documents with Tables and CheckBoxes using RadWordsProcessing]({%slug dynamic-docx-document-generation-radwordsprocessing%})

0 commit comments

Comments
 (0)