文本框数据拖拽

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

        private string MainLog = string.Empty;

        private void txtLog_DragDrop(object sender, DragEventArgs e)
        {
            txtLog.Clear();
            String[] files = e.Data.GetData(DataFormats.FileDrop, false) as String[];
            //Copy file from external application  
            foreach (string srcfile in files)
            {
                var log = File.ReadAllText(srcfile);
                string checkLog = ReadLog(log);
                txtLog.Text += checkLog;
            }

            SetColor();
        }

  

编辑器加载中...

原文地址:https://www.cnblogs.com/nywd/p/2270481.html