I have a ToolStrip with a ToolStripDropDownButton. This in turn pop up a UserControl with a DateTimePicker. When I click on the top numbers on the calendar (in green), everything works fine (user control stay open). When I click on one of the lower dates (in red), the ToolStripDropDown closes and the application loses focus. This causes the user to have to double click to open up the DropDown again (one time to focus the application, an other to open up the drop down).
This happens when the calender date are not on top of the user control. As you can see, the user control stops on the "green" dates.
I hope this is clear. This seems to be a windows bug since this happens with a very simple project. Have anyone seens this problem? Is there a fix for this?
[UPDATE]
I notice the same thing with dropdown.
It doesn't happen with the user control is very big.
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim uc As New UserControl1
Dim cms As New ContextMenuStrip()
cms.Items.Add(New ToolStripControlHost(uc))
ToolStripButton1.DropDown = cms
End Sub
Feature, not a bug. The control needs to know that the user clicked outside of the dropdown so it can then automatically close the dropdown. That's done with "mouse capture", exposed in Winforms by the Capture property. Capturing the mouse ensures that mouse messages are sent to the control, even if the mouse is no longer located inside the control window.
Perhaps it is obvious what's happening now, you are not in fact clicking on the calendar. Once the dropdown is displayed, the control captures the mouse. The click is redirected to the ToolStripDropDown. Which sees that the mouse is no longer inside the dropdown when you click in the "red area" and thus closes the dropdown window.
Dropdowns like this are really only suitable for simple items, putting any control inside of it that creates a toplevel window, like DateTimePicker or ComboBox just isn't a supported scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With