用如下代码,实现和微软Word同样的拖放功能,直接将图像、文本等文件经过鼠标拖拽的方式,放置入文档的当前输入位置。code
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); }注意TextChars.GetItem和Selection