Click here to Skip to main content
15,889,335 members
Home / Discussions / C#
   

C#

 
AnswerRe: Open PDF in RichTextBox Pin
Calin Tatar27-Feb-09 0:47
Calin Tatar27-Feb-09 0:47 
Questionconverting Pin
kanthgadu26-Feb-09 20:00
kanthgadu26-Feb-09 20:00 
AnswerRe: converting Pin
Christian Graus26-Feb-09 20:16
protectorChristian Graus26-Feb-09 20:16 
AnswerRe: converting Pin
Shyam K Pananghat26-Feb-09 20:30
Shyam K Pananghat26-Feb-09 20:30 
QuestionWMI service causes strange behaviour Pin
shabya26-Feb-09 19:59
shabya26-Feb-09 19:59 
AnswerRe: WMI service causes strange behaviour Pin
Calin Tatar26-Feb-09 22:32
Calin Tatar26-Feb-09 22:32 
GeneralRe: WMI service causes strange behaviour Pin
shabya26-Feb-09 22:43
shabya26-Feb-09 22:43 
QuestionDrag Drop listView Imagelist Images..... [modified] Pin
S K Y26-Feb-09 19:45
S K Y26-Feb-09 19:45 
Frown | :( Cry | :(( WTF | :WTF: hi i need help

im doing drag drop to listview imagelist images....selected images.my drag drop part cannot work...i tried so many type of coding but could't now im tring....creat another image list in listview 2 and add those selected items images in to that list view...i can add item text but cannot add image....anyone if can pl help me.....

thanks a lot here is my code...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Project_import_1
{
    public partial class ImportForm : Form
    {
        public ImportForm()
        {
            InitializeComponent();
        }
        OpenFileDialog dlg = new OpenFileDialog();
        

        private void import(object sender, EventArgs e)
        {            
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(100, 80);
            imageList.ColorDepth = ColorDepth.Depth32Bit;

            int i = 0;
            string[] files = dlg.FileNames;
            string[] pathes = new string[files.Length];

            foreach (string file in files)
            {
                pathes[i] = file;
                i++;
            }

            foreach (string path in pathes)
            {
                //Image img1 = Image.FromFile(path);
                //imageList.Images.Add(getThumbnaiImage   (imageList.ImageSize.Width, img1));
                imageList.Images.Add(Bitmap.FromFile(path));
                FileInfo fileInfo = new FileInfo(path);
                String strDir = fileInfo.Name;
                listView1.Items.Add(strDir);
                listView1.TileSize = new System.Drawing.Size(100, 80);

            }
            for (int j = 0; j < pathes.Length; j++)
            {
                //this.listView1.Items.Add("Picture"+(j+1));
                this.listView1.Items[j].ImageIndex = j;
            }
            this.listView1.View = View.LargeIcon;
            this.listView1.LargeImageList = imageList;

        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            dlg.Filter = "All Image Files|*.bmp;*.ico;*.gif;*.jpeg;*.jpg;" +
                                "*.jfif;*.png;*.tif;*.tiff;*.wmf;*.emf|" +
                         "Windows Bitmap (*.bmp)|*.bmp|" +
                         "Windows Icon (*.ico)|*.ico|" +
                         "Graphics Interchange Format (*.gif)|*.gif|" +
                         "JPEG File Interchange Format (*.jpg)|" +
                                "*.jpg;*.jpeg;*.jfif|" +
                         "Portable Network Graphics (*.png)|*.png|" +
                         "Tag Image File Format (*.tif)|*.tif;*.tiff|" +
                         "Windows Metafile (*.wmf)|*.wmf|" +
                         "Enhanced Metafile (*.emf)|*.emf|" +
                         "All Files (*.*)|*.*";
            dlg.InitialDirectory = @"C:\Documents and Settings\All  Users\Desktop\";
            dlg.Multiselect = true;

            try
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    import(sender, e);
                }
                dlg.Reset();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
       private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            
            this.listView1.DoDragDrop(this.listView1.SelectedItems[0], DragDropEffects.Copy);
        }
private void listView1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
       private void listView2_DragDrop(object sender, DragEventArgs e)
        {
ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
           
            this.listView2.View = View.LargeIcon;
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(100, 100);
            imageList.ColorDepth = ColorDepth.Depth32Bit;
            int i = 0;

                     
                foreach (ListViewItem each in listView1.SelectedItems)
                { 
                    listView2.Items.Add(item.Text, item.ImageIndex);
                    
                    //imageList.Images.Add(item.ImageIndex);
                    listView2.TileSize = new System.Drawing.Size(100, 80);
                }     
            for (int j = 0; j < listView1.SelectedItems.Count; j++)
            {
                this.listView1.Items[j].ImageIndex = j;               
            }
            this.listView2.View = View.LargeIcon;
            this.listView2.LargeImageList = imageList;
	  }

Sigh | :sigh: WTF | :WTF: OMG | :OMG: Cry | :(( Frown | :(

modified on Friday, February 27, 2009 2:01 AM

AnswerRe: Drag Drop listView Imagelist Images..... Pin
Calin Tatar26-Feb-09 22:26
Calin Tatar26-Feb-09 22:26 
GeneralRe: Drag Drop listView Imagelist Images..... Pin
S K Y1-Mar-09 2:16
S K Y1-Mar-09 2:16 
AnswerRe: Drag Drop listView Imagelist Images..... Pin
STeAlth-S26-Feb-09 23:17
STeAlth-S26-Feb-09 23:17 
GeneralRe: Drag Drop listView Imagelist Images..... Pin
S K Y1-Mar-09 2:43
S K Y1-Mar-09 2:43 
GeneralRe: Drag Drop listView Imagelist Images..... Pin
S K Y1-Mar-09 2:50
S K Y1-Mar-09 2:50 
Questionproject Pin
shobansama26-Feb-09 19:41
shobansama26-Feb-09 19:41 
AnswerRe: project Pin
Christian Graus26-Feb-09 20:16
protectorChristian Graus26-Feb-09 20:16 
GeneralRe: project Pin
CPallini26-Feb-09 22:16
mveCPallini26-Feb-09 22:16 
AnswerRe: project Pin
abdul jalil1-Mar-09 4:14
abdul jalil1-Mar-09 4:14 
Questionstring to datetime conversion ? Pin
Aghosh Babu26-Feb-09 19:28
Aghosh Babu26-Feb-09 19:28 
AnswerRe: string to datetime conversion ? Pin
Shyam K Pananghat26-Feb-09 20:13
Shyam K Pananghat26-Feb-09 20:13 
AnswerRe: string to datetime conversion ? Pin
Vikram A Punathambekar26-Feb-09 20:55
Vikram A Punathambekar26-Feb-09 20:55 
GeneralRe: string to datetime conversion ? Pin
Aghosh Babu26-Feb-09 21:01
Aghosh Babu26-Feb-09 21:01 
GeneralRe: string to datetime conversion ? Pin
J4amieC26-Feb-09 21:51
J4amieC26-Feb-09 21:51 
Questionhow to pass parameters to a delegate Pin
prasadbuddhika26-Feb-09 19:20
prasadbuddhika26-Feb-09 19:20 
AnswerRe: how to pass parameters to a delegate Pin
Shyam K Pananghat26-Feb-09 20:04
Shyam K Pananghat26-Feb-09 20:04 
GeneralRe: how to pass parameters to a delegate Pin
prasadbuddhika26-Feb-09 20:08
prasadbuddhika26-Feb-09 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.