为应用提供文件的拖放功能

来源:互联网 发布:ahp 判断矩阵 matlab 编辑:程序博客网 时间:2024/05/16 00:54
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace AppDrag{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void listBox1_DragEnter(object sender, DragEventArgs e)        {            if (e.Data.GetDataPresent(DataFormats.FileDrop))                e.Effect = DragDropEffects.All;            else                e.Effect = DragDropEffects.None;        }        private void listBox1_DragDrop(object sender, DragEventArgs e)        {            string[]s=(string[])e.Data.GetData(DataFormats.FileDrop,false);//GetData返回值为数组            for(int i=0;i<s.Length;i++)                listBox1.Items.Add(s[i]);        }    }}

0 0
原创粉丝点击