问什么我的textbox不能dragdrop,而dragover和dragenter都可以,allowdrop=true已经打开了 (没分了)

2004831 2004-11-01 10:04:43
问什么我的textbox不能dragdrop,而dragover和dragenter都可以,allowdrop=true已经打开了

private void textBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
MessageBox.Show("a");

}
label也一样不行

private void label1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
MessageBox.Show("a");
}

可是DragOver和DragEnter就可以,怎么回事啊。有没有高手帮帮我啊。
...全文
416 7 打赏 收藏 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnhgj 2004-11-06
  • 打赏
  • 举报
回复
你要写事件,鼠标才会变的

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;
}
2004831 2004-11-06
  • 打赏
  • 举报
回复
我试了,没有用你的代码,我自己弄了一个Form1_DragEnter
把FORM1的AllowDrop设为true,可是就是不行,鼠标的形状也没有变化,
是怎么会是啊
cnhgj 2004-11-06
  • 打赏
  • 举报
回复
以上示例是拖动一个文件后,在TEXTBOX中显示该文件的路径的例子。。

把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;
}

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() ;

}
cnhgj 2004-11-06
  • 打赏
  • 举报
回复
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)
{

}


}
}
2004831 2004-11-02
  • 打赏
  • 举报
回复
我是从资源管理器中拖一个文件过来
xiaoslong 2004-11-02
  • 打赏
  • 举报
回复
帮你顶
hujiiori 2004-11-02
  • 打赏
  • 举报
回复
DoDragDrop这个方法执行了没有?
内容概要:本文针对质子交换膜燃料电池(PEMFC)在动态压力工况下的最大功率点跟踪(MPPT)问题,提出了一种压力工况协同调控下的自适应高阶滑模控制策略,并基于Simulink平台完成了系统建模与仿真实现。该策略融合高阶滑模控制的强鲁棒性与自适应机制的参数在线优化能力,有效克服了PEMFC系统固有的非线性、外部扰动及工况时变性等挑战,实现了对最大功率点的快速、精确与稳定跟踪。研究内容涵盖控制策略的理论设计、李雅普诺夫稳定性分析、自适应律构建以及在多种动态工况下的仿真实验验证,结果表明该方法相较于传统控制策略具有更快的动态响应速度、更小的稳态振荡以及更强的抗干扰能力,显著提升了PEMFC系统的能量转换效率与运行稳定性。; 适合人群:具备一定控制理论基础和Simulink仿真经验,从事新能源发电系统、燃料电池控制、电力电子变换或先进控制算法研究的研发人员及高校研究生。; 使用场景及目标:①应用于燃料电池发电系统的高性能最大功率点跟踪控制设计;②为解决强非线性、多扰动耦合的能源系统提供先进的自适应鲁棒控制方案;③通过Simulink仿真验证高阶滑模与自适应控制算法的有效性,服务于科研项目攻关或工程原型开发。; 阅读建议:建议读者结合Simulink模型同步学习,重点关注控制律设计原理、自适应机制实现方式及仿真结果对比分析部分,并可通过与传统滑模控制进行对比,深入理解该策略在鲁棒性与动态性能上的优越性。
下拉可见数据集可视化效果示意。 【数据集概况】 · 检测类别(中文):[滴落物(Drop)] · 训练集:2021 张 · 验证集:128 张 · 测试集:42 张 · 总计:2191 张 该数据集聚焦于工业生产环境中地面或设备表面出现的各类滴落物检测,通过多角度、多光照条件下的图像采集,全面覆盖了不同形态、颜色和材质的滴落物样本。数据集真实还原了车间地面、金属板、木质结构等复杂背景下的实际场景,为自动化巡检系统提供了高价值的视觉依据,有助于实现对潜在污染源或泄漏点的早期识别与预警。... 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 71 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.8949** mAP50-95 | 0.5139 Precision | 0.8991 Recall | 0.8527 train/box_loss | 0.8544 train/cls_loss | 0.4842 val/box_loss | 1.5612 val/cls_loss | 0.6862 【训练过程分析】 71 轮训练后 mAP50 为 0.8949,模型基本收敛但还有提升余地。Loss 曲线下降正常,后期趋于平缓。mAP50-95 为 0.5139,和 mAP50 差距 0.38,定位精度是主要短板。 【模型性能评估】 Precision 0.8991、Recall 0.8527,精度高于召回,存在一定漏检。 【预测效果展示】 验证集预测效果较好,检测框基本准确覆盖滴落物,置信度整体偏高。 【改进建议】 1. 增强难例挖掘:在大规模数据中筛选误检...

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧