Hi, Is there a possibility to get the selected rows of one grid and put them inside the data source of another grid?I know that I need to use this line code:Ultragrid1.SelectedRows = Ultragrid1.Rows(0)Ultragrid2.Datasource =? But I don't know if it's correct, because i don't know how then to insert it inside the data source.Thanks
Hello Camilla,
You can insert the selected rows of one grid to another by obtaining its selected rows collection and then adding it to a data source of your choice. In the case of the sample that I am attaching, I am using data table as the data source of the second grid. For each selected row, a data row is created in the data table, after that the data row is populated by the contents of the cells of the row that is being iterated and then the data table is assigned as the data source for the grid and the rows collection is cleared.
Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.
Additionally, if you want to add rows to the selected rows collection programmatically you can do this by using the following line:
ultraGrid1.Selected.Rows.Add(ultraGrid1.Rows(1))
Let me know if you have any questions.
Regards, Ivan Kitanov
LoadSelectedRowsToAnotherGrid.zip
Hi,
I create a sub for selected rows like this:
Private Sub SelectedRows_GRD3()
Dim dt As DataTable = New DataTable() For Each row In GRD3.Selected.Rows Dim datarow As DataRow = dt.Rows.Add() datarow(0) = row.Cells("DESCRI").Value datarow(1) = row.Cells("U_ARPRZL").Value datarow(2) = row.Cells("P1").Value datarow(3) = row.Cells("QTA").Value
Next
grd3_stampa.DataSource = dt GRD3.Selected.Rows.Clear()
End Sub
but give me an error like " System.IndexOutOfRangeException :impossible to found column 0"
How I can do?