Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to drag the line in a line chart ?Do you have some examples?
Posted
Updated 26-Jun-12 20:09pm
v2

You first have to draw the line within some OnPaint method. In the process of doing so, you need to have its co-ordinates handy.

Dragging means to press a mouse button, move the mouse and release the button. On pressing the button (OnMouseDown), you get the current cursor co-ordinates. Check how they relate with your dragable line. You will want to define some hit area around the line because forcing your users to hit it exactly will drive them crazy.

If you decide to let the dragging start, do so and move the line's co-ordinates along with the mouse (OnMouseMove). Do so until user releases the mouse. Don't forget to Invalidate() your control every now and then or every moved pixel to actually see the dragging.

Stop dragging OnMouseUp.
 
Share this answer
 
<small></small>
[]&><
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900