今天在做textBox拖曳的功能,学到一点点
textBoxCmdName.AllowDrop = true;
textBoxCmdName.DragDrop += new DragEventHandler(txt_ObjDragDrop);
textBoxCmdName.DragEnter += new DragEventHandler(txt_ObjDragEnter);
private static void txt_ObjDragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Link;
}
private static void txt_ObjDragDrop(object sender, DragEventArgs e)
{
try
{
string FileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();//文件
System.Diagnostics.Process.Start("notepad", FileName);
//((TextBox)sender).Text = File.ReadAllText(FileName, Encoding.Default);
}
catch (Exception er)
{
Console.Write(er.Message);
}
}
版权声明:
作者:真爱无限 出处:http://www.pukuimin.top 本文为博主原创文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接.
Tags:
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
时间:2012-8-20 15:50:17
评论列表: