IDimSelection.SelectElement

Syntax

SelectElement(Element: Integer; Recursive: Boolean);

Parameters

Element. Index of the dictionary element to be added in the selection.

Recursive. Parameter determining whether child elements will be added to the selection. If True is sent, all child elements of specified element will be added to the selection.

Description

The SelectElement method adds the element with the Element index to the selection.

Comments

If the specified element cannot be selected (for example, the index of non-existing element is specified in the Element parameter), an exception is thrown. To add elements to the selection without displaying messages about possible exceptions, use the IDimSelection.SelectElementWithoutExcep method.

Example

Executing the example requires a form, a button named Button1 positioned on this form, the UiDimension component named UiDimension1, and the DimensionTree component named DimensionTree1. The data source of DimensionTree1 is UiDimension1. The dictionary of territories D_TO is attached to the UiDimension1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Inst: IDimInstance;
    Attr: IDimAttribute;
    AttrInst: IDimAttributeInstance;
    i: Integer;
Begin
    Inst := UiDimension1.DimInstance;
    Attr := Inst.Dimension.Attributes.Name;
    AttrInst := Inst.Attributes.FindByKey(Attr.Key);
    i := AttrInst.LookupValue("Administrative Region Sverdlovsk");
    If i <> -1 Then
        DimensionTree1.Selection.SelectElement(i, False);
        DimensionTree1.MakeVisible(i);
    End If;
End Sub Button1OnClick;

On clicking the button the method searches within the dictionary elements. The method searches by the name. Target value is Sverdlovsk region. If the element is found, it is selected in the DimensionTree1 component. Element tree is scrolled in such a way that the element found can be seen.

See also:

IDimSelection | IDimSelection.SelectElementWithoutExcep