码迷,mamicode.com
首页 > Windows程序 > 详细

C# textbox拖入路径

时间:2019-11-19 18:39:30      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:enter   one   vat   oid   link   路径   form   file   lse   

private void txt_file_DragDrop(object sender, DragEventArgs e)
{
((TextBox)sender).Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();

string strFileName = this.txt_file.Text.Trim();
if (strFileName == "") return;

if (strFileName.Substring(strFileName.Length - 4, 4) != ".csv"
&& strFileName.Substring(strFileName.Length - 4, 4) != ".CSV")
{
this.txt_file.Text = strFileName + ".csv";
}
}

private void txt_file_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}

C# textbox拖入路径

标签:enter   one   vat   oid   link   路径   form   file   lse   

原文地址:https://www.cnblogs.com/-jwj/p/11891363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!