【发布时间】:2011-03-23 23:46:17
【问题描述】:
我有一个使用 WCF 创建的上传/下载 Web 服务。我使用 c sharp 作为语言。
我在我的文本框上启用了允许拖放,该文本框接受要拖入其中的项目,但它不允许我这样做,我仍然没有悬停在它上面的迹象。
有什么我缺少的吗? 仅供参考,我使用完全相同的代码制作了另一个程序,并且可以毫无问题地拖放项目。
private void FileTextBox_DragEnter(object sender, DragEventArgs e)
{
//Makes sure that the user is dropping a file, not text
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
//Allows them to continue
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void FileTextBox_DragDrop(object sender, DragEventArgs e)
{
String[] files = (String[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
FileTextBox.Text = file.ToString();
}
}
【问题讨论】:
-
TextBox不是通过循环添加的合适控件。获取第一个文件或使用列表控件。 -
我认为你的意思是 WPF 而不是 WCF。