How can I get time in milliseconds for how long a button has been clicked
In C # how can I determine the time for how long a form button has been clicked down?
The simplest way is to use the tickcount which is already in milliseconds. Hope this code comes out alright:
private int i;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
i = System.Environment.TickCount;
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
i = System.Environment.TickCount - i;
MessageBox.Show(i.ToString());
}
Reply:Use the MouseDown %26amp; MouseUp events for the button to do a timestamp comparison between the events.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment