In my C # WinForms application, I use drag-and-drop to move items from a TreeView control to a Chart control. (This is a scheduling application with a list of tasks, and the user throws them into the schedule). When a user throws an element into an existing DataPoint in the diagram, I want the new element to become DataPoint and supplant the old one (moving it in the queue).
Here I have for the DragDrop event handler, which does not quite (but almost) work:
private void chart1_DragDrop(object sender, DragEventArgs e)
{
if (draggedJob != null)
{
HitTestResult testResult = chart1.HitTest(e.X, e.Y, ChartElementType.DataPoint);
switch (testResult.ChartElementType)
{
case ChartElementType.DataPoint:
DataPoint existingPoint = (DataPoint)testResult.Object;
JobOrder jobToDisplace = (JobOrder)existingPoint.Tag;
ScheduleJob(draggedJob, jobToDisplace);
break;
default:
ScheduleJob(draggedJob);
break;
}
RefreshTreeView();
RefreshChart();
draggedJob = null;
}
}
Can someone keep my sanity and help me figure out how I can determine which DataPoint user is quitting the job?
source
share