ListBox项目复制到datagridview [英] ListBox item copy to datagridview

查看:73
本文介绍了ListBox项目复制到datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表框和一个 datagridview .当我双击列表框的一个项目时,我想将其复制到datagridview的特定列单元格中.例如,如果我从列表框中选择项目"cd",则将使用cd值更新(特定列的)单元格. (列表框未连接到数据库)

如果有人知道可以帮助我..



我从列表框中获得了选定的项目...

 私有  void  listBox1_DoubleClick(对象发​​件人,EventArgs e)
        {
            字符串项目;
            item = listBox1.SelectedItem.ToString();
            MessageBox.Show("  + item);
        } 



然后我在考虑让datagridview单元格将鼠标复制到那里..

你怎么看?

谢谢!

解决方案

您最好的选择始终是更新数据源并重新绑定,而不是在控件之间移动数据.


i have a listbox and a datagridview. When I double click an item of the listbox, then I want to copy it to specific column cells of the datagridview. For example if i select from listbox the item "cd", then the cell (of specific column) to be update with the cd value. (listbox is not connect to the database)

If anyone knows to help me please..



I get the selected item from listbox...

private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            string item;
            item = listBox1.SelectedItem.ToString();
            MessageBox.Show("Selected Index = " + item);
        }



Then i am thinking to get the datagridview cell that my mouse is an copy it there..

What do you think.

Thanks!

解决方案

Your best bet is always to update the data source and rebind, not to move data between the controls.


这篇关于ListBox项目复制到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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