Alex Rivera | Logout

How to make a DateTimePicker increment/decrement on mouse wheel

Asked 2009-06-22T09:07:51.347
9

When you add a DateTimePicker control, you can select part of the control value (for example the month) and then use the up/down arrows to modify this part of the date/time value (for example, incrementing/decrementing the month).

What i would like to do is to allow the same thing with the mouse wheel. I tried to register on the event MouseWheel but I can't find a way to know which part of my date/time is currently selected, so I have no way to know if i should increment the time, the day, the month or the year.

Is there any way to do this ?

Edit
Report

1 Answer

0

Am not sure , but is this direction any good ..

Isnt it sure that , x coordinate for month < x for day < x for year (assuming no custom format) within the datepicker control , as its displayed along incresing x axis

then maybe we can capture the dateTimePicker1_MouseDown event and set the x coord where we clicked before the scroll in to a variable say:xCordOfClick , and then use this in Fiur's code for mousewheel to increment based on the difference in where we clicked and the x location of the datepicker .

something like

In dateTimePicker1_MouseDown(object sender, MouseEventArgs e)

    {
        xCordOfClick  = e.X;
    }

In mousewheel event

    {   
        //Do increment based on how far we clicked from the location of the control   
      // increment based on (xCordOfClick   - dateTimePicker1.Location.X).ToString() );
    }
answered 2009-06-22T11:42:23.737

Your Answer