ITabRange.DependentCells

Fore Syntax

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

Fore.NET Syntax

DependentCells(DirectOnly: Boolean): System.Array;

Parameters

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

If parameter is set to True, the method searches for all cells that directly depend on the given cell (Cells' formulas directly reference the given cell).

If parameter is set to False, the method finds all cells that directly or indirectly depend on the given cell.

Description

The DependentCells method finds cells that depend on the given cell.

Comments

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

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

Comment. A compound range is created based on the cells of one cell. The number of array elements matches the number of tables cells of which reference the given cell.

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 are required.

    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.DependentCells(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
                WinApplication.InformationBox("Could not find dependent cells.");
            End If;
        Else
            WinApplication.ExclamationBox("A single cell must be selected.");
        End If;
    End Sub Button1OnClick;

Click the button to find all cells that depend on the currently selected cell. 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.

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;
Imports Prognoz.Platform.Interop.Ui;

    Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
    Var
        Sheet: IPrxTable;
        Cell, DepRange, DepCell: ITabRange;
        Style: ITabCellStyle;
        Arr: Array;
        i, j: Integer;
        WinAppCls: WinApplicationClassClass = New WinApplicationClassClass();
        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.DependentCells(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
                WinAppCls.InformationBox("Could not find dependent cells.",
                    New IWin32WindowForeAdapter(Self));
            End If;
        Else
            WinAppCls.ExclamationBox("A single cell must be selected.",
                New IWin32WindowForeAdapter(Self));
        End If;
    End Sub;

On click the button all cells that depend on the currently selected cell are found. The borders of found cells are shown as a red line.

See also:

ITabRange