For selecting more than one rows in a DataGrid, check the IsMultiSelect property of the control:
The row collection can be accessed as follows:
//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.
In order to avoid adding the same information twice, the control exposes the “RetrieveCurrentValue” property, which controls whether the newValue/SelectedRow shoud be loaded
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.
public override void Opened()
{
base.Opened();
tbsBetriebsauftrag.NoResultFound += TbsBetriebsauftrag_OnNoResultFound;
}
On the Opened method you attach to the TextBox.
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