IDimElements.FindById

Syntax

FindById(Id: String): Integer;

Parameters

Id. Attribute value to be found.

Description

The FindById method searches element by value of the ID attribute.

Comments

Data type of the ID attribute may vary in different dictionaries. This method searches in string values, thus the target values need to be converted before search begins. If attribute value is found the method returns index of respective element; otherwise it returns -1.

Example

For the example to be executed, a form should exist. The form houses the following elements: Button, EditBox, , DimensionTree. The following event is described for the button: OnClick. The   component is linked to repository dictionary. Dictionary attribute that performs ID function has string type.

Class UserForm: Form
    Button1: Button;
    EditBox1: EditBox;
    UiDimension1: UiDimension;
    DimensionTree1: DimensionTree;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        Inst: IDimInstance;
        Elem: IDimElements;
        i: Integer;
    Begin
        Inst := UiDimension1.DimInstance;
        Elem := Inst.Elements;
        i := Elem.FindById(EditBox1.Text);
        If i <> -1 Then
            DimensionTree1.SetFocus;
            DimensionTree1.Selection.SelectElement(i, False);
        End If;
    End Sub Button1OnClick;
End Class UserForm;

After starting the form, point to the EditBox1 component and type in the value to be searched in values of the ID attribute. Click the button to start search process. If an element is found, the DimensionTree1 gets focus and the found element is added to selection.

See also:

IDimElements