On a toolbar manager button event I would like to process an action on each selected row of a specific band from an UltraGrid.
I have read many postings on this form but none of them explain clearly how to capture the selected rows of a specific band in the grid.
The grid band is [1] with the name "ttReceiptLines". Would prefer using names over index numbers (more clear for reading source which data object you work on).
What kind of object do I need to capture the selected rows? Can this be a RowsCollection?
How can I process each item of the collection to read info from them?
Need to identify the line number, the quantity and other line info to process and forward them to an other Receipt List.
Kind regards,
Peter Wokke
Hi Peter,
Thank you for posting in our forums.
You can get the selected rows from a specific band using the following line:
var selectedRows = ultraGrid1.Selected.Rows.OfType<UltraGridRow>().Where(r => r.Band.Key == "ttReceiptLines").ToList();
This will return you a collection of type List<UltraGridRow> and you can use the cells collection of each row to get the information you need when you are generating your Receipt List.
Please let me know if you have any additional questions.
Dimitar,
Thank you kindly for your replay.
Do not much understand the code in your example.
I develop in Progress and notation is different.
The dot separations I have to replace with :.
And example to get Info from the activeRow in Progress:
define variable iReceiptID as integer no-undo. define variable cStatus as character no-undo. define variable iPurposeID as integer no-undo. define variable clsSelectedRows as RowsCollection no-undo. define variable clsCurrentRow as UltraGridRow no-undo. define variable clsCells as CellsCollection no-undo. define variable clsCell as UltraGridCell no-undo. /* get to the ActiveRow ReceiptID */ if (ultraGridReceipt:ActiveRow <> ?) then do: clsCurrentRow = ultraGridReceipt:ActiveRow. clsCells = clsCurrentRow:Cells. clsCell = clsCells:item["ReceiptID"]. iReceiptID = integer(clsCell:Text). clsCell = clsCells:item["PurposeID"]. iPurposeID = integer(clsCell:Text). clsCell = clsCells:item["StatusCode"]. cStatus = clsCell:text. end.
This I do not understand at all:
OfType<UltraGridRow>().Where(r => r.Band.Key == "ttReceiptLines").ToList()
Is this a kind of casting?
Hope you can help on this?
Peter