Hi,
I'm working with the DataGrid and I've only had to select one row of the grid like that:
evaluacionActual1 = listaEvaluaciones[((DataRecord)(((DataPresenterBase)sender).ActiveRecord)).DataItemIndex];
listaEvaluaciones is the DataSource of the DataGrid, and now I want to select more than one row and add the rows to a new list of "Evaluacion". How can I do that ? I know the property "SelectedItems" but I don't know how to manage it or how to cast the selected items to my object.
I hope to hear from you soon!
thanks!!
pd: excuse me for my english!
Hello,
You can select multiple records either by setting their IsSelected property to true or adding them in the SelectedItems.Records collection. If you want to get the Data item of the record, you have to cast the Record to a DataRecord first which exposes the DataItem property:
Record r;
(r as DataRecord).DataItem...
Can you give me an example? If I have 3 records selected in the DataGrid, when I click on a button, I want to add them as an object (in this case, my custom object is Evaluacion) in a list. I trying to do what you said, but I didn't understand it so well.
I'm doing this, but when I run it, it doen't go into the foreach. It skips this part of code and I don't know why:
foreach (Record r in DataGridMaestro.Records) { if (r.IsSelected == true) { Evaluacion ev = new Evaluacion(); ev = (Evaluacion)(((DataRecord)r).DataItem); evaluacionesSeleccionadas.Add(ev); } }
thankss