Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a help for listview drag n drop opretion in winforms. where listview1 hold the images(LargeIcon) and when i double click on any images from listview1 it will delete from listview1 and show in listview2 and then when i click any button i want all paths of Images which is in the listview2. and also i want to set the image size(more then 256) on listview2. i am using imageList to show images in listview but its greater size is 256 that is not fulfill my requirement . Please help me. here is my code.

C#
string[] tempPath;
            ArrayList pathList = new ArrayList();
            bool flag;

             private void Form1_Load(object sender, EventArgs e)
                    {
                        this.sourceListView.View = View.LargeIcon;
                        this.SourceImageList.ImageSize = new Size(120, 120);
                        this.sourceListView.LargeImageList = this.SourceImageList;

                        DirectoryInfo dir = new DirectoryInfo("Images/");
                        var fileCount = (from file in Directory.EnumerateFiles("Images/", "*.bmp", SearchOption.AllDirectories) select file).Count();                   
                        foreach (FileInfo file in dir.GetFiles("*.bmp", SearchOption.AllDirectories))
                        {
                          this.SourceImageList.Images.Add(Image.FromFile(file.FullName));                 

                       }

                        for (int j = 0; j < this.SourceImageList.Images.Count; j++)
                        {
                            ListViewItem item = new ListViewItem();
                            item.ImageIndex = j;
                            this.sourceListView.Items.Add(item);
                        }
                }

           private void listView2_MouseDoubleClick(object sender, MouseEventArgs e)
                {
                    this.DestinationListView.View = View.LargeIcon;
                    this.DestinationListView.LargeImageList = this.DestinationImageList;                       
                    ListViewItem[] sel = new ListViewItem[1];
                    sel[0] = sourceListView.SelectedItems[0];
                    ListViewItem dragItem = sel[0];
                    DestinationImageList.ImageSize = new Size(256, 150);  // Want to more then this size that cover my whole panel.
this.DestinationImageList.Images.Add(SourceImageList.Images[dragItem.Index]);
this.DestinationImageList.Images.RemoveAt(DestinationImageList.Images.Count - 1);   

                    DestinationListView.Items.Clear();

                    for (int j = 0; j < this.DestinationImageList.Images.Count; j++)
                    {
                        ListViewItem item = new ListViewItem();
                        item.ImageIndex = j;
                        this.DestinationListView.Items.Add(item);
                    }

                    DestinationListView.Refresh();
                    sourceListView.Refresh();
                }
Posted
Updated 9-Mar-15 21:24pm
v3

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