如何将数据从一个datagridview移到另一个gridview [英] How to move the data from one datagridview into another gridview

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

问题描述

当我按下按钮时如何将数据从一个datagridview移动到另一个gridview如何在c#

How to move the data from one datagridview into another gridview when i press the button how to do this in windows form application in c#

推荐答案

private void dgvProducts_SelectionChanged(object sender, EventArgs e)
{
    if (this.dgvSelectedProducts.DataSource != null)
    {
        this.dgvSelectedProducts.DataSource = null;
    }
    else
    {
        this.dgvSelectedProducts.Rows.Clear();
    }
    for (int i = 0; i < dgvProducts.SelectedRows.Count; i++)
    {
        int index = dgvSelectedProducts.Rows.Add();
        dgvSelectedProducts.Rows[index].Cells[0].Value = dgvProducts.SelectedRows[i].Cells[0].Value.ToString();
        dgvSelectedProducts.Rows[index].Cells[1].Value = dgvProducts.SelectedRows[i].Cells[1].Value.ToString();
        .....
    }
}


这篇关于如何将数据从一个datagridview移到另一个gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆