Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Ultrawingrid
posted

If you select rows from a grid on one form and are trying to copy those selected rows to a grid on another form how would you accomplish this?

I'm trying the code below but the selected rows never copy over.  I've tried using  

loTable = oTable.Copy   but this copies every row from the current grid instead of just the selected rows.  Any help would be appreciated.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Private Sub cmdMerge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMerge.Click

Dim oTable As DataTable

 

 

Dim loTable As DataTable

 

 

Dim oItem As Infragistics.Win.UltraWinGrid.UltraGridRow

 

 

Try

Cursor.Current = Cursors.WaitCursor

 

 

If uGridMain.Selected.Rows.Count < 2 Then

MessageBox.Show(

"You must select at least two(2) " & AddressAlias & " records to be merged.", "Merge Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

 

 

Exit Sub

 

 

End If

 

 

Dim oForm As New frmMergeRecords

 

oTable = uGridMain.DataSource

loTable = oTable.Clone

oForm.uGridMain.DataSource = loTable

 

 

For Each oItem In uGridMain.Selected.Rows

oForm.uGridMain.BeginUpdate()

 

 

For intI As Integer = 1 To oItem.Cells.Count - 1

 

 

If TypeOf oItem.Cells(intI).Value Is Boolean Then

oForm.uGridMain.Rows.TemplateAddRow.Cells(intI).Value = oItem.Cells(intI).Value

 

 

Else

oForm.uGridMain.Rows.TemplateAddRow.Cells(intI).Value = oItem.Cells(intI).Text

 

 

End If

 

 

Next

oForm.uGridMain.EndUpdate()

 

 

Next

oForm.Text =

"Merge " & AddressAlias

oForm.AddressMerge =

True

oForm.ShowDialog()

LoadListView()

 

 

Catch ex As Exception

HandleError(ex, Name,

"cmdMerge_Click" )

 

 

Finally

Cursor.Current = Cursors.Default

 

 

End Try

 

 

End Sub