如何把DataGridView中的某一行数据复制到另一个DataGridView中??

sir_addict 2007-06-13 07:44:31
如何把DataGridView中的某一行数据复制到另一个DataGridView中
...全文
596 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yumanqing 2007-06-14
  • 打赏
  • 举报
回复
foreach (DataGridViewRow row in dgvPersonAll.Rows)
{
no = row.Cells[0].Value.ToString();
pcode = row.Cells[1].Value.ToString();
pname = row.Cells[2].Value.ToString();
if (row.Cells[3].Value != null)
{
js = row.Cells[3].Value.ToString();
}
else
{
js = "";
}
aRow = new string[] { no,pcode, pname, js };
dgvMgrPerson.Rows.Add(aRow);
}
sir_addict 2007-06-14
  • 打赏
  • 举报
回复
不用绑定可以实现吗??
fht123 2007-06-13
  • 打赏
  • 举报
回复
将datagridview1的某一行数据传给绑定datagridview2的表就可以了。

eg
newrow=table.new
for each
newrow("")=datagridview1的数据
table.rows.add(newrow)
next
datagridview2.datasource=table

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧