复制从DataGridView中选择的内容 [英] Copy Selected From DataGridView
问题描述
好的.我正在寻找解决方案.我有一个从数据集和数据库填充的datagridview1.我有另一个为空的datagridview2(这是目录数据库内的客户库存表).我希望用户能够从datagridview1中选择一行或一行,然后按下一个按钮,该按钮会将所选内容从datagridview1复制到目录数据库中到清单表中.我只是不确定如何解决这个问题.任何帮助将不胜感激.
致谢,
Bryan
Ok. I am looking for a solution. I have a datagridview1 that is populated from a dataset and a database. I have another datagridview2 that is empty (this is the customers inventory table inside the catalog database). I want the user to be able to select a row or rows from datagridview1 and push a button that would copy the selection from datagridview1 to the catalog database into the inventory table. I just not sure how to approach this. Any help would be appreciated.
Regards,
Bryan
推荐答案
Krossley,SelectedRows属性将使您获得DataGridViewRows的集合.被选中.每个DataGridViewRow的DataBoundItem属性将从选定的数据集中获取表格行.然后,您需要复制该行以填充绑定到第二个datagridview的数据表... Chuck
Krossley, The SelectedRows property will get you the collection of DataGridViewRows that are selected. The DataBoundItem property of each DataGridViewRow will get you the table row from the dataset that was selected. You will then need to duplicate this row to populate the datatable that is bound to the second datagridview...Chuck
这篇关于复制从DataGridView中选择的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!