Skip to main content
All docs
V25.1
  • TdxAutomationElementSettings.OnCalculateProperty Event

    Allows you to modify individual UIA node properties depending on certain conditions.

    Declaration

    property OnCalculateProperty: TdxCalculateAutomationPropertyEvent read; write;

    Remarks

    You can handle the OnCalculateProperty event to modify individual UIA node properties depending on certain conditions (for example, you can define different node descriptions for different parent control states).

    Event Occurrence

    The OnCalculateProperty event occurs every time a UIA client requests an individual node property (multiple times – once per node property).

    Automatic and Manual UIA Property Calculation

    Automatic
    Default. The OnCalculateProperty event occurs automatically for each UIA node property in supported DevExpress controls only if the dxUIACalculateAllProperties global variable is set to True.
    Manual

    You can set the dxUIACalculateAllProperties variable to False to disable automatic calculation for all UIA properties. In this mode, handle the OnInitializeProperties event for each required DevExpress control to specify individual UIA node properties you need to calculate.

    Refer to the OnInitializeProperties event description for detailed information and code examples.

    Event Parameters

    The following parameters are available within an OnCalculateProperty event handler:

    ASender
    Provides access to the control/UI element that raised the OnCalculateProperty event.
    AProperty

    Provides access to the calculated UI node property.

    You can use this parameter to identify the calculated UIA node property as demonstrated in the code example below.

    AProperties

    Provides access to the list of all UIA node properties for the parent control.

    You can use AProperties.Name and AProperties.FullDescription properties to modify corresponding UIA node properties for the parent control (ASender).

    Refer to the TdxCalculateAutomationPropertyEvent procedural type description for detailed information on all parameters accessible within an OnCalculateProperty event handler.

    Code Example: Indicate Read-Only and Editable States

    The code example in this section changes the description of an unbound single-line text editor (TcxTextEdit) in the UI Automation tree when the editor switches between read-only and editable states.

    uses
      dxUIAClasses,  // Declares all UI Automation classes
      cxEdit,  // Declares base editor classes and auxiliary types
      cxTextEdit;  // Declares the TcxTextEdit class
    // ...
    
    procedure TMyForm.cxTextEdit1PropertiesAutomationCalculateProperty(
      ASender: TObject; AProperty: TdxAutomationProperty;
      AProperties: TdxAutomationProperties);
    var
      AEdit: TcxTextEdit;
    begin
      AEdit := ASender as TcxTextEdit;
      // Check if the UIA node description property is requested
      if AProperty = AProperties.FullDescription then
      begin
        if AEdit.Properties.ReadOnly then
          AProperties.FullDescription.Value := 'Read-Only Mode'
        else
          AProperties.FullDescription.Value := 'Editable';
      end;
    end;
    
    See Also