标题: RichTextBox 文件拖动 [打印本页] 作者: gxm771208 时间: 2016-10-28 12:29 标题: RichTextBox 文件拖动 功能:设置可以拖拽的文件类型,将文本异步显示到RichTextBox。
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
class gxRichTextBox:System.Windows.Forms.RichTextBox
{
private delegate void ReadFileOneByOne(string FilePath);
public gxRichTextBox()
{
this.AllowDrop = true;//接受拖拽
this.AcceptsTab = true;//接受TAB键
this.DragDrop += new System.Windows.Forms.DragEventHandler(gxRichTextBox_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(gxRichTextBox_DragEnter);
}
private string _gxFilter = "txt,sql,asm";
[Description("可以打开的文件类型,以 ,分割开")]
public string GxFilter
{
get { return _gxFilter; }
set { _gxFilter = value; }
}