在MS Word中,你可以将一个文件拖拽到Word中,然后会在原有文件中插入拖入文件的内容。此功能在TX Text Control中很方便的实现。
要实现此功能,我们可以使用TextControl的DragDrop事件,在该事件的处理函数中添加以下代码:
private void textControl1_DragDrop(object sender, DragEventArgs e)
{
Point posCursor = textControl1.PointToClient(new Point(e.X, e.Y));
TXTextControl.TextChar txChar =
textControl1.TextChars.GetItem(posCursor, true);
textControl1.Selection.Start = txChar.Number;
textControl1.Selection.Load(fileDragDrop.FileName,
fileDragDrop.StreamType);
}
