ApiCheckBoxForm
Class representing a document checkbox / radio button.
Properties
Name |
Type |
Description |
radio |
boolean |
Specifies if the current checkbox is a radio button. In this case, the key parameter is considered as an identifier for the group of radio buttons. |
Methods
Name |
Description |
Clear |
Clears the current form. |
Copy |
Copies the current form (copies with the shape if it exists). |
GetClassType |
Returns a type of the ApiFormBase class. |
GetFormKey |
Returns the current form key. |
GetFormType |
Returns a type of the current form. |
GetRadioGroup |
Returns the radio group key if the current checkbox is a radio button. |
GetText |
Returns the text from the current form.
This method is used only for text and combo box forms. |
GetTextPr |
Returns the text properties from the current form.
This method is used only for text and combo box forms. |
GetTipText |
Returns the tip text of the current form. |
GetWrapperShape |
Returns a shape in which the form is placed to control the position and size of the fixed size form frame.
The null value will be returned for the inline forms. |
IsChecked |
Returns the state of the current checkbox (checked or not). |
IsFixed |
Checks if the current form is fixed size. |
IsRadioButton |
Checks if the current checkbox is a radio button. |
IsRequired |
Checks if the current form is required. |
SetBackgroundColor |
Sets the background color to the current form. |
SetBorderColor |
Sets the border color to the current form. |
SetChecked |
Checks the current checkbox. |
SetFormKey |
Sets a key to the current form. |
SetPlaceholderText |
Sets the placeholder text to the current form.
Can't be set to checkbox or radio button. |
SetRadioGroup |
Sets the radio group key to the current radio button. |
SetRequired |
Specifies if the current form should be required. |
SetTextPr |
Sets the text properties to the current form.
This method is used only for text and combo box forms. |
SetTipText |
Sets the tip text to the current form. |
ToFixed |
Converts the current form to a fixed size form. |
ToInline |
Converts the current form to an inline form.
Picture form can't be converted to an inline form, it's always a fixed size object. |
Example
Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oCheckBoxForm = Api.CreateCheckBoxForm({"tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": true});
oCheckBoxForm.SetRadioGroup("Marital status");
var oParagraph = oDocument.GetElement(0);
oParagraph.AddElement(oCheckBoxForm);
oParagraph.AddText(" Married");
oParagraph.AddLineBreak();
oCheckBoxForm = Api.CreateCheckBoxForm({"tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": true});
oCheckBoxForm.SetRadioGroup("Marital status");
oParagraph.AddElement(oCheckBoxForm);
oParagraph.AddText(" Single");
var sRadioGroup = oCheckBoxForm.GetRadioGroup();
var bRadioButton = oCheckBoxForm.IsRadioButton();
oCheckBoxForm.SetChecked(true);
var bChecked = oCheckBoxForm.IsChecked();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The second checkbox from this document is a radio button: " + bRadioButton);
oParagraph.AddLineBreak();
oParagraph.AddText("The second checkbox from this document is checked: " + bChecked);
oParagraph.AddLineBreak();
oParagraph.AddText("Radio group name of the radio buttons in this document: " + sRadioGroup);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiCheckBoxForm.docx");
builder.CloseFile();
Resulting document