DateTimePicker - changes the value value "back" when right clickingoutside the component

S

Sonnich Jensen

Hi

I have a problem with the DateTimePicker.

1) i open the drop down
2) step months back/forth
3) while the drop down is open, move the mouse to some (any) other
point and right click

At this moment the DateTimePicker will fire the "value changed" event
with the original values, then the "CloseUp" event.

This is a problem, as the right click is used our app.

Any way to avoid this? And why does this happen anyway?

Sonnich
 
R

Registered User

Hi

I have a problem with the DateTimePicker.
I've tried to replicate this behavior using a forms app in VS2010 with
the .NET 4 client profile. What I found was
1) i open the drop down
2) step months back/forth

moving month to month fires the control's ValueChanged event. This is
appropriate as the selected value changes with the month.
3) while the drop down is open, move the mouse to some (any) other
point and right click
Right-clicking within the dropdown presents a context menu with the
single selection "Go to today".
At this moment the DateTimePicker will fire the "value changed" event
with the original values, then the "CloseUp" event.

This is a problem, as the right click is used our app.

Any way to avoid this? And why does this happen anyway?
I am unable to reproduce the problem as described so I can offer no
insights.

One question : Is it necessary to use the control as a drop-down? With
the ShowUpDown property set to true, a selection can be made using a
spinbutton instead of the dropdown calendar.

regards
A.G.
 
S

Sonnich Jensen

I've tried to replicate this behavior using a forms app in VS2010 with
the .NET 4 client profile. What I found was


moving month to month fires the control's ValueChanged event. This is
appropriate as the selected value changes with the month.


When the drop down is open, move to a "component free" place on the
form/panel , and right click there

I have VS2008 and run it on XP (.net 3.5)

Sonnich

Right-clicking within the dropdown presents a context menu with the
single selection "Go to today".




I am unable to reproduce the problem as described so I can offer no
insights.

One question : Is it necessary to use the control as a drop-down? With
the ShowUpDown property set to true, a selection can be made using a
spinbutton instead of the dropdown calendar.

For the ranges and system we use, I guess it is. I will check this
feature tomorrow at work,
 
R

Registered User

When the drop down is open, move to a "component free" place on the
form/panel , and right click there
I don't see any unexpected behavior. Clicking outside of the control
simply changes the scope/focus and the dropdown closes. The
ValueChanged event does not fire when that happens.
- snip -
For the ranges and system we use, I guess it is. I will check this
feature tomorrow at work,
As long as the dropdown calendar is not a must have, the spinbutton
should work fine business.

regards
A.G.
 
S

Sonnich Jensen

I don't see any unexpected behavior. Clicking outside of the control
simply changes the scope/focus and the dropdown closes. The
ValueChanged event does not fire when that happens.

In my case it does - here is my log (with comments):

29.12.2011 12:21:16.096 ------started--------
29.12.2011 12:21:17.218 enter [got focus]
29.12.2011 12:21:17.729 dtpErrorStart_MouseLeave [this means going to
the drop down window, which appreantly is not a part of the
DateTimePicker]
29.12.2011 12:21:18.810 dtpErrorEnd_ValueChanged: False, 29.11.2011
12:21:16 - 29.12.2011 12:21:16 [stepping in the calendar]
29.12.2011 12:21:19.151 dtpErrorEnd_ValueChanged: False, 29.10.2011
12:21:16 - 29.12.2011 12:21:16 [stepping in the calendar]
29.12.2011 12:21:19.662 dtpErrorEnd_ValueChanged: False, 29.09.2011
12:21:16 - 29.12.2011 12:21:16 [stepping in the calendar]
29.12.2011 12:21:20.192 dtpErrorEnd_ValueChanged: False, 29.08.2011
12:21:16 - 29.12.2011 12:21:16 [stepping in the calendar]
[here I move the mouse to the side, and it is on the form]
29.12.2011 12:21:21.454 dtpErrorEnd_ValueChanged: False, 29.12.2011
12:21:16 - 29.12.2011 12:21:16 [****this comes when I right click
on the form****]
29.12.2011 12:21:21.454 dtpErrorStart_CloseUp

dtpErrorEnd and Start uses the same "value changed". When one of them
changes I rerun my query. All event are from the same component.

Once again, this is VS2008, NET3.5 on Win XP
The ValueChanged with the original time does not come when I left
click.

Sonnich
 
S

Sonnich Jensen

I don't see any unexpected behavior. Clicking outside of the control
simply changes the scope/focus and the dropdown closes. The
ValueChanged event does not fire when that happens.

In my case it does - here is my log (with comments):

29.12.2011 12:21:16.096 ------started--------
29.12.2011 12:21:17.218 enter   [got focus]
29.12.2011 12:21:17.729 dtpErrorStart_MouseLeave  [this means going to
the drop down window, which appreantly is not a part of the
DateTimePicker]
29.12.2011 12:21:18.810 dtpErrorEnd_ValueChanged: False, 29.11.2011
12:21:16 - 29.12.2011 12:21:16   [stepping in the calendar]
29.12.2011 12:21:19.151 dtpErrorEnd_ValueChanged: False, 29.10.2011
12:21:16 - 29.12.2011 12:21:16   [stepping in the calendar]
29.12.2011 12:21:19.662 dtpErrorEnd_ValueChanged: False, 29.09.2011
12:21:16 - 29.12.2011 12:21:16   [stepping in the calendar]
29.12.2011 12:21:20.192 dtpErrorEnd_ValueChanged: False, 29.08.2011
12:21:16 - 29.12.2011 12:21:16   [stepping in the calendar]
[here I move the mouse to the side, and it is on the form]
29.12.2011 12:21:21.454 dtpErrorEnd_ValueChanged: False, 29.12.2011
12:21:16 - 29.12.2011 12:21:16    [****this comes when I right click
on the form****]
29.12.2011 12:21:21.454 dtpErrorStart_CloseUp

dtpErrorEnd and Start uses the same "value changed". When one of them
changes I rerun my query. All event are from the same component.

Once again, this is VS2008, NET3.5 on Win XP
The ValueChanged with the original time does not come when I left
click.

Sonnich

This action make me think, it is like it is a way of cancelling the
selection, but that is not the case - it is funny, that the Validating
event comes before the ValueChanged event....


29.12.2011 18:50:47.012 dtpErrorStart_MouseLeave
29.12.2011 18:50:47.633 dtpErrorEnd_ValueChanged: False, 29.11.2011
18:50:45 - 29.12.2011 18:50:45
29.12.2011 18:50:48.024 dtpErrorEnd_ValueChanged: False, 29.10.2011
18:50:45 - 29.12.2011 18:50:45
29.12.2011 18:50:48.394 dtpErrorEnd_ValueChanged: False, 29.09.2011
18:50:45 - 29.12.2011 18:50:45
29.12.2011 18:50:48.795 dtpErrorEnd_ValueChanged: False, 29.08.2011
18:50:45 - 29.12.2011 18:50:45
29.12.2011 18:50:54.583 dtpErrorEnd_ValueChanged: False, 29.12.2011
18:50:45 - 29.12.2011 18:50:45
29.12.2011 18:50:54.603 dtpErrorStart_CloseUp
29.12.2011 18:51:02.024 dtpErrorStart_Validating: False (<e.Cancel)
29.12.2011 18:51:02.024 dtpErrorStart_Validated



The design is requested so
 
R

Registered User

-snip -
I don't see any unexpected behavior. Clicking outside of the control
simply changes the scope/focus and the dropdown closes. The
ValueChanged event does not fire when that happens.

In my case it does - here is my log (with comments):

29.12.2011 12:21:16.096 ------started--------
29.12.2011 12:21:17.218 enter   [got focus]
29.12.2011 12:21:17.729 dtpErrorStart_MouseLeave  [this means going to
the drop down window, which appreantly is not a part of the
DateTimePicker]
- snip -

This action make me think, it is like it is a way of cancelling the
selection, but that is not the case - it is funny, that the Validating
event comes before the ValueChanged event....
-snip-
The design is requested so
It is very likely the unexpected behavior you describe is a
side-effect of the design. Create a forms app, drop a DateTimePicker
control on the form, and run the app. Compare how the control behaves
in the simple app versus the app you're working on. That should
demonstrate where the problem isn't.

regards
A.G.
 
S

Sonnich Jensen

-snip -
I don't see any unexpected behavior. Clicking outside of the control
simply changes the scope/focus and the dropdown closes. The
ValueChanged event does not fire when that happens.
In my case it does - here is my log (with comments):
29.12.2011 12:21:16.096 ------started--------
29.12.2011 12:21:17.218 enter   [got focus]
29.12.2011 12:21:17.729 dtpErrorStart_MouseLeave  [this means going to
the drop down window, which appreantly is not a part of the
DateTimePicker]
- snip -
This action make me think, it is like it is a way of cancelling the
selection, but that is not the case - it is funny, that the Validating
event comes before the ValueChanged event....
-snip-
The design is requested so

It is very likely the unexpected behavior you describe is a
side-effect of the design. Create a forms app, drop a DateTimePicker
control on the form, and run the app. Compare how the control behaves
in the simple app versus the app you're working on. That should
demonstrate where the problem isn't.

Well, the problem remain. Just the component itself does this, with a
form and the component. Right clicking on the form when the drop down
is open cause the same - the DTP returns to it original value
Try it yourself

Sonnich
 
R

Registered User

On Fri, 30 Dec 2011 01:29:48 -0800 (PST), Sonnich Jensen

- much snippage -
Well, the problem remain. Just the component itself does this, with a
form and the component. Right clicking on the form when the drop down
is open cause the same - the DTP returns to it original value
Try it yourself
I have tried it. Previously in this thread I described the control's
behavior as being nothing similar to what you're experiencing. A
right-click on the DateTimePicker's dropdown displays a context menu.

When you tried it, was it in a new forms app or just in an empty form
in your app? I suspect the latter because in the original post it was
written

- quote -
This is a problem, as the right click is used our app.
- end quote -

One thing to note is the control does not expose its MouseClick event.
This makes sense because on the dropdown a left-click indicates a
selection while a right-click brings up a built-in context menu.

All this leads me to believe that somewhere in the application mouse
messages are being hooked in order to promote the app's right click
behavior. This would explain the unexpected behavior of the
DateTimePicker control.

regards
A.G.
 
S

Sonnich Jensen

On Fri, 30 Dec 2011 01:29:48 -0800 (PST), Sonnich Jensen


- much snippage -


I have tried it. Previously in this thread I described the control's
behavior as being nothing similar to what you're experiencing. A
right-click on the DateTimePicker's dropdown displays a context menu.

not on the drop down, but OUTSIDE the DTP - click on the form itself
then the date turns back to the original

I see the context menu too (select today)
When you tried it, was it in a new forms app or just in an empty form
in your app? I suspect the latter because in the original post it was
written

that is what I am doing now :)
 
R

Registered User

not on the drop down, but OUTSIDE the DTP - click on the form itself
then the date turns back to the original
OK. With the DTP dropdown open clicking either mouse button on the
control's container changes the focus. When this occurs the dropdown
closes but the control's ValueChanged event does not fire.
I see the context menu too (select today)


that is what I am doing now :)
It is difficult to blame the DTP control. As I understand it the
unexpected behavior only occurs after focus is changed by specifically
right-clicking on a different control.

regards
A.G.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top