Add Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WPF. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
Description
Inserts an instance of the class ConditionalInstruction to the collection and the document.
Syntax
public bool Add(ConditionalInstruction conditionalInstruction);Public Function Add(conditionalInstruction As ConditionalInstruction) As BooleanParameters
| Parameter | Description |
|---|---|
| conditionalInstruction | Specifies |
Return Value
The return value is true, if the ConditionalInstruction could be added. Otherwise false. A ConditionalInstruction element won't be added, if the TextControl.IsFormFieldValidationEnabled property is set to false or the TextControl.EditMode is set to EditMode.ReadAndSelect and TextControl.DocumentPermissions.ReadOnly to true.
Examples
The following example registers a conditional rule for an approval check box in a fillable form.
CheckFormField approval = new(false) { Name = "Approved" };
textControl.FormFields.Add(approval);
ConditionalInstruction rule = new()
{
Conditions = new[] { new Condition(approval, true) },
Instructions = new[] { new Instruction(approval, Instruction.InstructionTypes.IsEnabled, true) }
};
if (!textControl.FormFields.ConditionalInstructions.Add(rule))
{
throw new InvalidOperationException("The approval rule could not be added.");
}Dim approval As New CheckFormField(False) With { .Name = "Approved" }
textControl.FormFields.Add(approval)
Dim rule As New ConditionalInstruction() With {
.Conditions = New Condition() { New Condition(approval, True) },
.Instructions = New Instruction() { New Instruction(approval, Instruction.InstructionTypes.IsEnabled, True) }
}
If Not textControl.FormFields.ConditionalInstructions.Add(rule) Then
Throw New InvalidOperationException("The approval rule could not be added.")
End IfRemarks
A System.ArgumentException is thrown, if the Name property value of the added ConditionalInstruction object is null or already exists as the name of another ConditionalInstruction inside the collection. Furthermore an exception is thrown, if the ConditionalInstruction's Condtions or Instructions properties values do not contain elements.