Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
how to export a picture from listview(form2) to picturebox(in form1) ?

Copied here from answer for OP

So, i don't know in 100% how do that, i'm new in c# and i need that for school, i never before use the c#...unfortunately. I found something like that:
C#
ListViewItem selection = ListView1.GetItemAt(e.X, e.Y);
// If the user selects an item in the ListView, display
// the image in the PictureBox.
if (selection != null)
{
    PictureBox1.Image = System.Drawing.Image.FromFile(
        selection.SubItems[1].Text);

But it doesn't work for me. I know I ask for a lot, but please, help me.
Posted
Updated 16-Jan-11 6:11am
v2

If form1 opens form2, do the following:

1. Create a public handler for the ItemChecked or ItemSelection changed event and handle it in the Form1.
2. The parameter sender in form1 will give all the information about the selected image in the ListView. Use that to show it in the PictureBox.

If not, then:
1. Have a static (depends on the application) property in the Form1 to represent the PictureBox image.
2. On user action in form2, set this property of the form1 which inturn should set the PictureBox image.

If a static property does not suit your application, use Application.OpenForms collection to access the current instance of Form1 and then do same.

Update after OP comment: I think you should go through the book or any other material then. Me spoon-feeding you with the code is not going to help in long run.
 
Share this answer
 
v4
Comments
Manfred Rudolf Bihy 16-Jan-11 12:14pm    
Comment on behalf of OP:
I modified my question. I tried something but it didn't work. Please have a look.
forestwow 16-Jan-11 12:31pm    
I understand, but i need this only for this project to school, and then i dont need c# anymore...Please, I understand this is not to good way, but i really need this...
This below sample will help you to understand how to get the subitem clicked on ListView.sample[^]

For passing from one form to another,you can follow the above steps mentioned.
 
Share this answer
 

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