I have a mousemove event that takes the position of the cursor and outputs it to two labels (X and Y), the value dynamically changes as I hover around. I have a mousedown event that when clicked, the same values are outputted to a textbox. How can I combine the mousedown and mousemove events so that when I hover AND hold down the mouse button, the textbox value dynamically changes as I move.
2
votes
How about storing a variable that when the mouse is down, you set the variable e.g. IsMouseLeftButtonDown bool; When you move the mouse, you can check the variable and only set the textbox value if the test passes
- Pieter Germishuys
Can you please, some more brief? you want to display the Mouse Move points or the Mouse Down points in the Text Box?
- Sai Kalyan Kumar Akshinthala
3 Answers
6
votes
2
votes
Track the mouse down and mouse up events to set a variable determining whether or not the mouse button is pressed (ie set in down unset in mouse up) then just check this variable in mouse_move
see http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousebuttons.aspx for an example