ListBox项目复制到datagridview [英] ListBox item copy to 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屋!