我想实现的功能就是鼠标在IE里选择了一个string,然后把这个string用鼠标拖到自己的程序上面.程序上的textbox就能显示这个string.请问这能实现吗?

解决方案 »

  1.   

                // 
                // textBox1
                // 
                this.textBox1.AllowDrop = true;
                this.textBox1.Location = new System.Drawing.Point(12, 12);
                this.textBox1.Multiline = true;
                this.textBox1.Name = "textBox1";
                this.textBox1.Size = new System.Drawing.Size(268, 231);
                this.textBox1.TabIndex = 0;
                this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(textBox1_DragEnter);
                this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);
     
    //=========================================
            void textBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
            {
                e.Effect = System.Windows.Forms.DragDropEffects.Copy;
            }        void textBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(string)))
                {
                    textBox1.Text = (string)(e.Data.GetData(typeof(string)));
                }
            }