Torna al Thread

Dim dtSource, dtSource1 As DataTable Dim SourceRowIndex As Integer = -1 Private Sub DataGridView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragOver If SourceRowIndex >= 0 Then e.Effect = DragDropEffects.Move End If End Sub Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown SourceRowIndex = -1 Dim record As String If e.Button = Windows.Forms.MouseButtons.Left Then SourceRowIndex = DataGridView1.HitTest(e.X, e.Y).RowIndex DataGridView1.Rows(SourceRowIndex).Selected = True record = DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).Cells(0).Value.ToString record = record + ";" + (DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).Cells(1).Value.ToString) record = record + ";" + (DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).Cells(2).Value.ToString) record = record + ";" + (DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).Cells(3).Value.ToString) record = record + ";" + (DataGridView1.Rows(DataGridView1.SelectedRows(0).Index).Cells(4).Value.ToString) DoDragDrop(record, DragDropEffects.Copy) dtSource.Rows.RemoveAt(SourceRowIndex) End If End Sub Private Sub DataGridView2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView2.DragEnter Dim strtemp As String Dim strtemplist(4) As String Dim newRow As DataRow = dtSource1.NewRow strtemp = e.Data.GetData(DataFormats.Text) ' recupera i dati associati alla stringa strtemplist = Split(strtemp, ";") For i = 0 To 4 newRow.Item(i) = strtemplist(i) Next dtSource1.Rows.Add(newRow) DataGridView2.DataSource = dtSource1 End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5