# xTextBoxSearch

## Multiselection

For selecting more than one rows in a DataGrid, check the IsMultiSelect property of the control:

![](/files/-MYEbJnxQ1Zlprls-vz1)

The row collection can be accessed as follows:

```csharp
//IEnumerable of DataRows, containing all the selected rows from the DataGrid
var selRowsOt = dxgStueckOverview.SelectedRows;        
foreach (var item in selRowsOt)
    rowList.Add(item);    // one DataRow    
```

## xTextBoxSearch MultiSelection

When setting the IsMultiSelect property on the xTextBoxSearch, the control will contain a collection of rows in the ExtraRows property. The value provided in ItemChanged control should be retrieved, while each element in the ExtraRows property must be added.

When performing search using F8/F9 on the control or by clicking on the search icon, the first row in the selection goes into the newValue/SelectedRow, while the 2nd row until the last are added in the ExtraRows property. When performing a drag & drop from the Navigator, the 1st row until the last are added in the ExtraRows property.&#x20;

{% hint style="info" %}
In order to avoid adding the same information twice, the control exposes the “RetrieveCurrentValue” property, which controls whether the newValue/SelectedRow shoud be loaded
{% endhint %}

```csharp
public override void ItemChanged(UIElement container, FrameworkElement element, object selectedItem, object newValue, object oldValue)
{
    base.ItemChanged(container, element, selectedItem, newValue, oldValue);

    if (Equals(element, tbsArbgkatNrPos))
    {    
        BusObj.RetrieveArbgkat(afoRow, newValue.ToString());
        
        // Multiselection 
        foreach (var arbgRow in tbsArbgkatNrPos.ExtraRows)
        {
            var arbg = arbgRow["id"].ToString();
            if (arbg != newValue.ToString())
            {
                var newAfoRow = BusObj.NewBabAfo(SelectedStlPosition);
                BusObj.RetrieveArbgkat(newAfoRow, arbg);
            }
        }
    }
}
```

## xTextBoxSearch NoResultFound

This event is triggers when no result is found following a search.

```csharp
public override void Opened()
{
   base.Opened();
   tbsBetriebsauftrag.NoResultFound += TbsBetriebsauftrag_OnNoResultFound;
}
```

On the Opened method you attach to the TextBox.

```csharp
protected void TbsBetriebsauftrag_OnNoResultFound(object sender, EventArgs e)
{
    var searchedBaNr = sender as string;

    var message = string.Empty;
    if (searchedBaNr.ToInt(0) != 0)
    {
        var baRow = Sql.SelectRow("select status, typ, art from bab where bab.nr = :babNr", new { babNr = searchedBaNr });
        if (baRow == null)
        {
            message = l.Translate("Betriebsauftrag {0} ist nicht vorhanden.", searchedBaNr.ToInt(0));
        }
        else
        {
            var status = baRow["status"].ToInt(0);
            var baTyp = baRow["typ"].ToInt(0);
            var art = baRow["art"].ToInt(0);

            if (baTyp != Enums.BabTyp.Betriebsauftrag || !art.In(Enums.BabArt.Einzelprodukt, Enums.BabArt.Koppelprodukt, Enums.BabArt.Nacharbeitsauftrag, Enums.BabArt.NacharbeitsauftragKoppelproduktBetriebsauftrag))
            {
                message = l.Translate("{0} ist nicht als Einzel-/Koppelbetriebsauftrag geschlüsselt.", searchedBaNr.ToInt(0));
            }
            else if (status == (int)EnumBaStatus.Abgewickelt)
            {
                message = l.Translate("Betriebsauftrag {0} ist abgewickelt.", searchedBaNr.ToInt(0));
            }
        }
    }

    Log.Error(l.Translate("Fehler beim Laden des Betriebsauftrags. {0}", message));
    tbsBetriebsauftrag.CommitChanges();
    NewKopf();  // reset RM
}
```

The implementation of TbsBetriebsauftrag\_OnNoResultFound, sender will have the searched text, on searchedBabNr = sender as string. This implementation is found in wndRM


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tldocs.gitbook.io/documentation/framework/controls/multiselection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
