VB.net Programmably drop down the DateTimePicker

风格不统一 提交于 2019-12-31 05:19:07

问题


Hey all i have this code here:

Call SendMessage(dtPicker.Handle, CB_SHOWDROPDOWN, True, 0&)

That works fine on comboboxes but doesn't seem to work when it comes to the DateTimePicker box.

What could be the problem?

Thanks!

David


回答1:


No, that's for a ComboBox. The native DTP control is quite noddy. It supports the DTM_CLOSEMONTHCAL message to close the calendar but doesn't have a corresponding message to open it. You'll have to do something ugly like faking mouse or keyboard input. The latter is probably best:

Private Sub ShowMonthCalendar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowMonthCalendar.Click
    DateTimePicker1.Focus()
    SendKeys.Send("{F4}")
End Sub


来源:https://stackoverflow.com/questions/5597880/vb-net-programmably-drop-down-the-datetimepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!