问什么我的textbox不能dragdrop,而dragover和dragenter都可以,allowdrop=true已经打开了 (没分了) DoDragDrop这个方法执行了没有? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace TreeDnD{ /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(72, 152); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(280, 21); this.textBox1.TabIndex = 2; this.textBox1.Text = "textBox1"; // // Form1 // this.AllowDrop = true; this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(496, 341); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { System.Array myarr =(System.Array) e.Data.GetData(DataFormats.FileDrop); System.Collections.IEnumerator myEnumerator = myarr.GetEnumerator(); myEnumerator.MoveNext() ; textBox1.Text=myEnumerator.Current.ToString() ; } private void Form1_Load(object sender, System.EventArgs e) { } }} 以上示例是拖动一个文件后,在TEXTBOX中显示该文件的路径的例子。。把FORM1的AllowDrop设为trueprivate void Form1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { System.Array myarr =(System.Array) e.Data.GetData(DataFormats.FileDrop); System.Collections.IEnumerator myEnumerator = myarr.GetEnumerator(); myEnumerator.MoveNext() ; textBox1.Text=myEnumerator.Current.ToString() ; } 我试了,没有用你的代码,我自己弄了一个Form1_DragEnter把FORM1的AllowDrop设为true,可是就是不行,鼠标的形状也没有变化,是怎么会是啊 你要写事件,鼠标才会变的private void Form1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } 关于WebResponse获取少量内容的问题的。。 帮帮忙,参数修改,急!!! 求助:Socket异步接收问题,BeginReceiveFrom总是报错,不知道如何解决 求C#函数集 求教关键ansi编码问题 郁闷!谁能帮我看看为什么这段话会报错? GDI+问题 ,请有经验的高手指教!!!在线等!万分感谢! 如何禁止asp.net 内联模式code-inline的运行 access数据库的问题 去除字符串中的Html标记,但要求保留类似“<阿斯顿>”这样的字符 [STAThread]和[DllImport...]的疑问 在线等待 请教怎样在代码里执行sql server的系统存储过程
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace TreeDnD
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent(); //
// TODO: Add any constructor code after InitializeComponent call
//
} /// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 152);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(280, 21);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "textBox1";
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(496, 341);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
this.ResumeLayout(false); }
#endregion /// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
} private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
System.Array myarr =(System.Array) e.Data.GetData(DataFormats.FileDrop);
System.Collections.IEnumerator myEnumerator = myarr.GetEnumerator();
myEnumerator.MoveNext() ;
textBox1.Text=myEnumerator.Current.ToString() ; } private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
} private void Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
System.Array myarr =(System.Array) e.Data.GetData(DataFormats.FileDrop);
System.Collections.IEnumerator myEnumerator = myarr.GetEnumerator();
myEnumerator.MoveNext() ;
textBox1.Text=myEnumerator.Current.ToString() ; }
把FORM1的AllowDrop设为true,可是就是不行,鼠标的形状也没有变化,
是怎么会是啊
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}