Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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...

C#
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!
Posted
Updated 28-Jul-11 13:03pm
v2
Comments
Orcun Iyigun 28-Jul-11 20:17pm    
If your gridview pulls its data from db, to get around this you can update it from the db and refresh the gridview.
hadjidemetriou 30-Jul-11 8:58am    
Ok, thanks a lot!

1 solution

Your best bet is always to update the data source and rebind, not to move data between the controls.
 
Share this answer
 
Comments
hadjidemetriou 30-Jul-11 8:58am    
Ok, thanks a lot!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900