ReportBox.OnBeforeObjectChange

Syntax

OnBeforeObjectChange (Sender: Object; Args: IReportObjectChangeEventArgs);

OnBeforeObjectChange (Sender: object; Args: Prognoz.Platform.Interop.Report.ReportObjectChangeEventArgs);

Parameters

Sender. Component generated event.

Args. Parameters of the object, in which an event occurred.

Description

The OnBeforeObjectChange event occurs before changing an object.

Comments

Object parameters can be cast to various interfaces depending on the type of change on an object. To do it, use the IReportObjectChangeEventArgs.Type property value returned by the Args parameter:

After an object is changed, the OnAfterObjectChange event occurs.

Example

Executing the example requires a form containing the ReportBox component named ReportBox1 and the UiReport component named UiReport1 which is a data source for ReportBox1. Set the OperationMode property of the UiReport1 component to Edit, the Active property to True. UiReport1 must contain loaded regular report with shapes on active sheet.

The specified procedure must be assigned by handler of the OnBeforeObjectChange event for the ReportBox1 component.

Instead of the Fore components use Fore.NET analogs.

Add links to the Drawing, Report, Tab system assemblies.

Sub ReportBox1OnBeforeObjectChange(Sender: Object; Args: IReportObjectChangeEventArgs);
Var
    Rect: IReportBeforeObjectRectChangeEventArgs;
    Angle: IReportBeforeObjectAngleChangeEventArgs;
    RectPos: IGxRectF;
Begin
    
Select Case Args.Type
         // If object is rotated more than 90 degrees, cancel rotation
        Case TabObjectChangeType.Angle:
            Angle := Args 
As IReportBeforeObjectAngleChangeEventArgs;
            
If Angle.NewValue > 90 Then
                Angle.Cancel := 
True;
            
End If;
         // If object's bottom border is moved lower than 100 pixels, cancel moving 
        Case TabObjectChangeType.Rect:
            Rect := Args 
As IReportBeforeObjectRectChangeEventArgs;
            RectPos := Rect.NewValue;
            
If RectPos.Bottom > 100 Then
                Rect.Cancel := 
True;
            
End If;
    
End Select;
End Sub ReportBox1OnBeforeObjectChange;

Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;

Sub ReportBoxNet1OnBeforeObjectChange(Sender: object; Args: Prognoz.Platform.Interop.Report.ReportObjectChangeEventArgs);
Var
    Rect: IReportBeforeObjectRectChangeEventArgs;
    Angle: IReportBeforeObjectAngleChangeEventArgs;
    RectPos: IGxRectF;
Begin
    
Select Case Args.Type
         // If object is rotated more than 90 degrees, cancel rotation
        Case TabObjectChangeType.toctAngle:
            Angle := Args 
As IReportBeforeObjectAngleChangeEventArgs;
            
If Angle.NewValue > 90 Then
                Angle.Cancel := 
True;
            
End If;
         // If object's bottom border is moved lower than 100 pixels, cancel moving 
        Case TabObjectChangeType.toctRect:
            Rect := Args 
As IReportBeforeObjectRectChangeEventArgs;
            RectPos := Rect.NewValue;
            
If RectPos.Bottom > 100 Then
                Rect.Cancel := 
True;
            
End If;
    
End Select;
End Sub ReportBoxNet1OnBeforeObjectChange;

After executing the example rotation more than 90 degrees and moving of the bottom border lower than 100 pixels is canceled for all the shapes on the sheet.

See also:

ReportBox