تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
نقل الداتا الموجودة في داتا جريد فيو الي داتا جريد فيو أخري
#2
كود :
Private Sub Gridv1_to_gricv()

       DataGridView1.CancelEdit()
       DataGridView1.Columns.Clear()
       DataGridView1.DataSource = Nothing

       Dim sourceGrid As DataGridView = Me.DataGrid1
       Dim targetGrid As DataGridView = Me.DataGridView1

       'Copy all rows and cells.

       Dim targetRows = New List(Of DataGridViewRow)

       For Each sourceRow As DataGridViewRow In sourceGrid.Rows

           If (Not sourceRow.IsNewRow) Then

               Dim targetRow = CType(sourceRow.Clone(), DataGridViewRow)

               'The Clone method do not copy the cell values so we must do this manually.
               'See: https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewrow.clone(v=vs.110).aspx

               For Each cell As DataGridViewCell In sourceRow.Cells
                   targetRow.Cells(cell.ColumnIndex).Value = cell.Value
               Next

               targetRows.Add(targetRow)

           End If

       Next

       'Clear target columns and then clone all source columns.

       targetGrid.Columns.Clear()

       For Each column As DataGridViewColumn In sourceGrid.Columns
           targetGrid.Columns.Add(CType(column.Clone(), DataGridViewColumn))
       Next

       'It's recommended to use the AddRange method (if available)
       'when adding multiple items to a collection.

       targetGrid.Rows.AddRange(targetRows.ToArray())
   End Sub
الرد }}}
تم الشكر بواسطة: ﻣﺒﺘﺪﺉ


الردود في هذا الموضوع
RE: نقل الداتا الموجودة في داتا جريد فيو الي داتا جريد فيو أخري - بواسطة Rabeea Qbaha - 25-11-17, 01:43 AM


التنقل السريع :


يقوم بقرائة الموضوع: