IMetabaseListView.SelectElem

Syntax

SelectElem(Object: IMetabaseObjectDescriptor, [Focus: Boolean = False]);

Parameters

Object. Description of repository object.

Focus. Indicates whether to focus element.

Description

The SelectElem method selects a component element corresponding to the repository object with the specified description.

Comments

If the component enables multiple selection, the element will be added to the list of already selected elements.

Example

Executing the example requires a form with the button named Button1 on it and the MetabaseListView component named MetabaseListView1. A repository folder is selected in the Root property for the MetabaseListView component.

Add links to the ExtCtrls, Metabase system assemblies.

The example is a handler of the OnClick event for the Button1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Descs: IMetabaseObjectDescriptors;
    Desc: IMetabaseObjectDescriptor;
Begin
    // Get repository object description
    Desc := MetabaseListView1.GetItemObject(MetabaseListView1.Items.Item(1As IMetabaseListViewItem);
    // Select the element corresponding to the repository object with the specified description
    MetabaseListView1.SelectElem(Desc);
    Descs := MetabaseListView1.SelectedObjects;
    // Display the number of objects in the selected folder and selected objects in the console
    Debug.WriteLine("Total objects: " + MetabaseListView1.Items.Count.ToString);
    Debug.WriteLine("Selected objects: " + MetabaseListView1.SelectedCount.ToString);
    Debug.Indent;
    For Each Desc In Descs Do
        Debug.WriteLine(Desc.Name + " (" + Desc.Id + ')');
    End For;
    Debug.Unindent;
End Sub Button1OnClick;

After executing the example two first elements in the component are selected, the console window displays the number of elements in the selected folder, the number of selected elements, names and identifiers of selected components.

See also:

IMetabaseListView