第一步:设置zedGraph的AllowDrop属性为true
第二步:编写zedGraph的DragEnter和DragDrop函数,具体如下
//用鼠标将文件拖动到画图区域
private void zedGraphControl1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
//鼠标完成拖动文件
private void zedGraphControl1_DragDrop(object sender, DragEventArgs e)
{
//文件路径
string filePath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
}