ITabRange.DependenceCells

Fore Syntax

DependenceCells([DirectOnly: Boolean = True]): Array;

Fore.NET Syntax

DependenceCells(DirectOnly: Boolean): System.Array;

Parameters

DirectOnly. The parameter that determines a method that is used to find dependent cells.

If the parameter value is True, the cells which directly determine the selected cell are to be found (the formula of the selected cell contains a direct link to the cell).

If the parameter value is False, all the cells which directly or indirectly determine the selected cell are to be found.

Description

The DependenceCells method finds cells, which determine the selected cell.

Comments

This method can be executed only for a single-cell range.

An array is created as a result of method execution. Each cell of this array contains a compound cell range formulas of which reference the current cell.

NOTE. A compound range is created based on the cells of one cell. The number of array items corresponds to the number of tables containing the cells, that determine the way the current cell is calculated.

Fore Example

To execute the example a form, a button named Button1 positioned on this form, the UiReport component named UiReport1, and the ReportBox component that displays data of the regular report linked to UiReport1 arerequired.

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

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        Sheet: IPrxTable;
        Cell, DepRange, DepCell: ITabRange;
        Style: ITabCellStyle;
        Arr: Array Of Variant;
        i, j: Integer;
    Begin
        Sheet := (UiReport1.Instance As IPrxReport).ActiveSheet As IPrxTable;
        Cell := Sheet.TabSheet.View.Selection.Range;
        If Cell.Count = 1 Then
            Arr := Cell.DependenceCells(False);
            If Not IsNull(Arr) And (Arr.Length > 0Then
                For i := 0 To Arr.Length - 1 Do
                    DepRange := Arr[i] As ITabRange;
                    For j := 0 To DepRange.PartCount - 1 Do
                        DepCell := DepRange.Part(j);
                        Style := DepCell.Style;
                        Style.BorderColor(TabBorder.Outline) := GxColor.FromName("Red");
                        Style.BorderStyle(TabBorder.Outline) := TabBorderStyle.Continuous;
                    End For;
                End For;
            Else
                Debug.WriteLine("Dependent cells are not found.");
            End If;
        Else
            Debug.WriteLine("Only one cell should be selected.");
        End If;
    End Sub Button1OnClick;

On clicking the button, all cells that determine the currently selected cell, are to be found. The borders of found cells are shown as a red line.

Fore.NET Example

To execute the example a form, a button named Button1 positioned on this form, the UiReportNet component named UiReportNet1, and the ReportBoxNet component that displays data of the regular report linked to UiReportNet1 are required.

Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;

    Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
    Var
        Sheet: IPrxTable;
        Cell, DepRange, DepCell: ITabRange;
        Style: ITabCellStyle;
        Arr: Array;
        i, j: Integer;
        GxColorCls: GxColorClassClass = New GxColorClassClass();
    Begin
        Sheet := (UiReportNet1.ReportUi.Instance As IPrxReport).ActiveSheet As IPrxTable;
        Cell := Sheet.TabSheet.View.Selection.Range;
        If Cell.Count = 1 Then
            Arr := Cell.DependenceCells(False);
            If Not (Arr = NullAnd (Arr.Length > 0Then
                For i := 0 To Arr.Length - 1 Do
                    DepRange := Arr[i] As ITabRange;
                    For j := 0 To DepRange.PartCount - 1 Do
                        DepCell := DepRange.Part[j];
                        Style := DepCell.Style;
                        Style.BorderColor[TabBorder.tbOutline] := GxColorCls.FromName("Red");
                        Style.BorderStyle[TabBorder.tbOutline] := TabBorderStyle.tbsContinuous;
                    End For;
                End For;
            Else
                System.Diagnostics.Debug.WriteLine("Dependent cells are not found.",
            End If;
        Else
            System.Diagnostics.Debug.WriteLine("Only one cell should be selected.",
        End If;
    End Sub;

On clicking the button, all cells that determine the currently selected cell, are to be found. The borders of found cells are shown as a red line.

See also:

ITabRange