Public Class Form1 Dim artykulySource As New BindingSource Dim l1Source As New BindingSource Dim artykulyview As New DataView Dim l1view As New DataView Dim l1 As New DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Database1DataSet.artykuly' table. You can move, or remove it, as needed. Me.ArtykulyTableAdapter.Fill(Me.Database1DataSet.artykuly) artykulySource = ArtykulyDataGridView.DataSource artykulyview = CType(artykulySource.List, DataView) l1 = artykulyview.DataViewManager.DataSet.Clone l1Source.DataSource = l1 l1Source.DataMember = "artykuly" l1view = CType(l1Source.List, DataView) DataGridView1.DataSource = l1Source End Sub Private Sub Moveartykul(ByRef source As DataGridView, ByRef target As DataView) For i = 0 To source.SelectedRows.Count - 1 Dim row As DataRowView row = target.AddNew() Dim col As Int16 = 0 For Each cell As DataGridViewCell In source.SelectedRows(i).Cells row.Item(col) = cell.Value col = col + 1 Next Dim cena As Single cena = source.SelectedRows(i).Cells(1).Value Label1.Text = Math.Round(Label1.Text + cena, 2) Next 'delete the copied items from the source table Dim count As Int16 = source.SelectedRows.Count For i = 0 To count - 1 source.Rows.RemoveAt(source.SelectedRows(0).Index) Next End Sub Private Sub reMoveartykul(ByRef source As DataGridView, ByRef target As DataView) For i = 0 To source.SelectedRows.Count - 1 Dim row As DataRowView row = target.AddNew() Dim col As Int16 = 0 For Each cell As DataGridViewCell In source.SelectedRows(i).Cells row.Item(col) = cell.Value col = col + 1 Next Dim cena As Single cena = source.SelectedRows(i).Cells(1).Value Label1.Text = Math.Round(Label1.Text - cena, 2) Next 'delete the copied items from the source table Dim count As Int16 = source.SelectedRows.Count For i = 0 To count - 1 source.Rows.RemoveAt(source.SelectedRows(0).Index) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Moveartykul(ArtykulyDataGridView, l1view) 'sort the items in the target datagrid ArtykulyDataGridView.Sort(ArtykulyDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Ascending) l1Source.MoveLast() l1Source.MoveFirst() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click reMoveartykul(DataGridView1, artykulyview) 'sort the items in the target datagrid ArtykulyDataGridView.Sort(ArtykulyDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Ascending) artykulySource.MoveLast() artykulySource.MoveFirst() End Sub End Class