TX Text Control .NET for Windows Forms

Instruction Class

Class|Introduced in 28.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.dll
Install
dotnet add package TXTextControl.TextControl.WinForms.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Implements
IComparable

Description

An object of the Instruction class is an element of the ConditionalInstruction class and represents actions that are execute´d when the corresponding conditions are fulfilled.

To specify such an instruction, the Instruction object has to be initialized with a FormField that is located inside the document. That form field is the object for which the desired actions are executed.

In this context, up to four different types of actions can be executed: Changing the FormField.Enabled property, marking the form field value as valid or invalid, setting a new value and replacing the SelectionFormField.Items array with another string array. On invoking an instance of the Instruction class, one of these types has to be set to the instructionType parameter by using one of the corresponding Instruction.InstructionTypes enumeration values.

To specify a value that is set by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are fulfilled, the constructor's instructionValue parameter must be used. A value that is applied when the corresponding conditions are not fulfilled, can be set by the elseInstructionValue parameter of the constructor's second overload.

Syntax

public class Instruction : IComparable

Examples

The following example builds a rule around an approval check box in a fillable form.

CheckFormField approvalField = new(false) { Name = "Approved" };
textControl.FormFields.Add(approvalField);
Instruction instruction = new(approvalField, Instruction.InstructionTypes.IsEnabled, true);

Members

Constructors

ConstructorDescription
InstructionInitializes a new instance of the Instruction class to determine an action that is executed when the defined requirements of the ConditionalInstruction.Conditions array are fulfilled or not fulfilled.

Properties

PropertyDescription
ElseInstructionValueGets the value that is set by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are not fulfilled and the Instruction.IsElseInstructionEnabled property is set to true.
FormFieldGets the FormField to which the specified action is executed.
InstructionTypeGets the type of action to execute. It specifies how the instruction value and else instruction value is applied to the corresponding form field.
InstructionValueGets the value that is set by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are fulfilled.
IsElseInstructionEnabledGets or sets a value indicating whether this Instruction allows to execute else instructions. If this property is set to true, the else instruction value is applied by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are not fulfilled. The default value is false, if no else instruction value was set by the instruction constructor. Otherwise true.
IsFormFieldChangeInstructionGets or sets a value indicating whether this Instruction listens to value changes of the related conditions' form fields. If this property is set to false, the instruction ignores any form field change that would cause an action. Otherwise the corresponding actions are executed. The default value is true.
IsInitialInstructionGets or sets a value indicating whether this Instruction is handled when the document is initialized as a form. By default, all conditional instructions are applied when the document is changed to or loaded as a form. In this context, if this property is set to false, the instruction does not execute any actions, even if the requirements are fulfilled. The default value is true.

Methods

MethodDescription
CompareToNot described in the reference. public int CompareTo(object obj);

Enumerations

EnumerationDescription
InstructionTypesDetermines the type of action to execute. The enumeration contains the following values: