Good morning,
I contact cause I made my own user control to create a spin box. The spin box has two buttons for increase and decrease the value. I would like to create an event in order to increase or decrease the value (depend the case) when I stayed cliked, in continous, on the button. It is not the only click on the button it it is when I stay the left button down and the value continue to increase automatically.
Do someone know the name of the event I have to used ? I tried "PreviewMouseLeftButtonDown" but it gives the same behavior than a "Click".
Thank you in advance for your answer.
Shweta LodhaPosted Jun 4, 2014, 12:28 PM
RomainPosted Jun 4, 2014, 10:10 AM
Shweta LodhaPosted Jun 4, 2014, 5:24 AM
You can achieve this by using Timer. Please have a look at this sample code:
private void incrementbutton_MouseDown(object sender, MouseEventArgs e)
{
timer1.Enabled = true;
timer1.Start();
}
private void incrementbutton_MouseUp(object sender, MouseEventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
// increment your counter here
}