IRdsDictionaryElementsSearch.FindFirst

Fore Syntax

FindFirst: Integer;

Fore.NET Syntax

FindFirst: UInteger;

Description

The FindFirst method searches the first element that meets search conditions and returns key of the found element if search was successful.

Comments

Method returns -1 if element was not found.

Fore Example

Executing the example requires a form with the Button1 button, the RdsDictionaryBox component named RdsDictionaryBox1, and the UiRdsDictionary component that is a data source for RdsDictionaryBox1. The MDM dictionary that is connected to the UiRdsDictionary component has the attributes Name and UserAttr.

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        RdsInst: IRdsDictionaryInstance;
        Search: IRdsDictionaryElementsSearch;
        Crit: IDimTextCriteria;
        Key: Integer;
    Begin
        RdsInst := RdsDictionaryBox1.Source.Instance;
        Search := RdsInst.CreateSearch;
        Search.Attributes.Attributes := "Name;UserAttr";
        Crit := New DimTextCriteria.Create;
        Crit.CriteriaOptions := TextCriteriaOptions.SearchStringAttributes
            Or TextCriteriaOptions.FreeText;
        Crit.Text := Income of the population;
        Search.SetTextCriteria(Crit);
        Key := Search.FindFirst;
        Debug.WriteLine(Key);
        Key := Search.FindNext(Key);
        Debug.WriteLine(Key);
    End Sub Button1OnClick;

After executing the example, pressing the button searches the first two elements of the MDM dictionary with the specified parameters of search criterion. Search is executed on values of specified attributes. Keys of found elements are displayed in the development environment console.

Fore.NET Example

Executing the example requires .NET form with the Button1 button, the RdsDictionaryBoxNet component named RdsDictionaryBoxNet1 and any UiRdsDictionaryNet component used as data source for RdsDictionaryBoxNet1. The MDM dictionary that is connected to the UiRdsDictionaryNet component has the attributes Name and UserAttr.

    Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
    Var
        RdsInst: IRdsDictionaryInstance;
        Search: IRdsDictionaryElementsSearch;
        Crit: DimTextCriteria;
        Key: UInteger;
    Begin
        RdsInst := RdsDictionaryBoxNet1.Source.Instance;
        Search := RdsInst.CreateSearch();
        Search.Attributes.Attributes := "Name;UserAttr";
        Crit := New DimTextCriteria();
        Crit.CriteriaOptions := TextCriteriaOptions.tecropSearchStringAttributes
            Or TextCriteriaOptions.tecropFreeText;
        Crit.Text := Income of the population;
        Search.SetTextCriteria(Crit);
        Key := Search.FindFirst();
        Text := Key.ToString();
        Key := Search.FindNext(Key);
        Text := Text + " " + Key.ToString();
    End Sub;

After executing the example, pressing the button searches the first two elements of the MDM dictionary with the specified parameters of search criterion. Search is executed on values of specified attributes. Keys of found elements are displayed in the form header.

See also:

IRdsDictionaryElementsSearch