将选定的行从一个DGV复制到另一个DGV [英] Copying selected rows from one DGV to another DGV

查看:108
本文介绍了将选定的行从一个DGV复制到另一个DGV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能给我一个想法,如何将所选行从一个datagridview复制到另一个datagridview中,这些行必须以相同的顺序显示.就像从DGV1中选择的行将是

第1行
第2行
第3行


DGV2还会以相同的顺序显示复制的行,与上面的不一样

第3行
第2行
第1行


在此先感谢

Hi,

Can anyone give me an idea of how to copy selected rows from one datagridview to another datagridview provided by the order rows should be displayed in the same order. Like the selected rows in from DGV1 will be

row 1
row 2
row 3


the DGV2 also display the copied rows in same order as above not like

row 3
row 2
row 1


Thanks in advance

推荐答案

在这里看看如何复制行:
http://social.msdn.microsoft.com/论坛/en-US/csharpgeneral/thread/b10ba6b8-677c-4629-b1ed-ec45086d33dd [ http://msdn.microsoft.com/en-us/library/x8x9zk5a.aspx [ ^ ]

祝你好运!
Have a look here about how to copy the rows:
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/b10ba6b8-677c-4629-b1ed-ec45086d33dd[^]

...and to get the selected rows:
http://msdn.microsoft.com/en-us/library/x8x9zk5a.aspx[^]

Good luck!


我认为这是因为您正在遍历源DGV并使用Add方法将它们附加到目标吗?
最简单的方法是不使用添加",而是使用插入"-这样,您可以精确指定要在行列表中放置项目的位置.
I assume this is happening because you are looping through the source DGV and using the Add method to append them to the destination?
The easiest way is not to use Add, but Insert instead - that way you can specify exactly where in the Rows list you want the items.


选中此

http://bytes.com/topic/c-sharp/answer/899342-how-copy-rows-one-datagridview-another [ http://stackoverflow.com/questions/6891267/copying-rows-from- one-datagridview-to-another [ ^ ]

http://stackoverflow.com/questions/6172867/复制数据从一个datagridview到另一个inc锐化 [ http://social.msdn.microsoft.com /Forums/zh-CN/winformsdatacontrols/thread/ae9bee8d-e2ac-43c5-9b6d-c799d4abb2a3/ [
Check this

http://bytes.com/topic/c-sharp/answers/899342-how-copy-rows-one-datagridview-another[^]

http://stackoverflow.com/questions/6891267/copying-rows-from-one-datagridview-to-another[^]

http://stackoverflow.com/questions/6172867/copy-data-from-one-datagridview-to-another-in-c-sharp[^]

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/ae9bee8d-e2ac-43c5-9b6d-c799d4abb2a3/[^]


这篇关于将选定的行从一个DGV复制到另一个DGV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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