SelectElem(Object: IMetabaseObjectDescriptor, [Focus: Boolean = False]);
Object. Description of repository object.
Focus. Indicates whether to focus element.
The SelectElem method selects a component element corresponding to the repository object with the specified description.
If the component enables multiple selection, the element will be added to the list of already selected elements.
Executing the example requires a form, a button with the Button1 identifier on this form, the MetabaseListView component with the MetabaseListView1 identifier. Any repository folder is selected in the Root property of the MetabaseListView component.
Add links to the ExtCtrls, Metabase system assemblies.
The example is the OnClick event handler 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(1) As IMetabaseListViewItem);
// Select the element which corresponds 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 to 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 will be selected, the console window will display: the number of elements in the selected folder, the number of selected elements, names and identifiers of selected components.
See also: