本文介绍了如何将一个datagridview的选定行移动到另一个datagridview。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个datagridview(dgvFrom和dgvTo)和2个带左右箭头的按钮。 dgvfrom从数据集中填充。现在,当我在dgvFrom中选择行并单击右箭头按钮时,选定的行应该移动到dgvTo网格,这些选定的行应该从dgvFrom网格中删除。反之亦然,左箭头按钮。可以帮助我。

I have 2 datagridview (dgvFrom and dgvTo) and 2 buttons with right and left arrows. dgvfrom is populated from dataset. Now when I select rows in dgvFrom and click right arrow button, selected rows should move to dgvTo grid and those selected rows should get deleted from dgvFrom grid.and vice versa for left arrow button.Can any1 help me with this.

推荐答案

Dim DsTo As New DataSet '''' '''' Dataset for to DatagridView

'''' '''' Code on button Click
      for DgvToFor Each r As DataGridViewRow In DGVFrom.SelectedRows
           Dim Drto As DataRow = DsTo.Tables(0).NewRow
           For c As Integer = 0 To DGVFrom.ColumnCount - 1
               Drto(c) = r.Cells(c).Value
           Next
           DsTo.Tables(0).Rows.Add(Drto)
           DGVFrom.Rows.Remove(r)
       Next







RKS




RKS



这篇关于如何将一个datagridview的选定行移动到另一个datagridview。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 18:21