تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
نقل الداتا الموجودة في داتا جريد فيو الي داتا جريد فيو أخري
#5
(25-11-17, 02:20 AM)Rabeea Qbaha كتب : قمت بتحميل الملف والتعديل على الكود ليناسبك 

فقط استدعي المثود Gridv1_to_gricv()  في زر ال Transfere 


كود :
Private Sub Gridv1_to_gricv()

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

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

       '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: نقل الداتا الموجودة في داتا جريد فيو الي داتا جريد فيو أخري - بواسطة khaled12345 - 25-11-17, 02:52 AM


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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم