VB.net可编程地下拉DateTimePicker [英] VB.net Programmably drop down the DateTimePicker

查看:141
本文介绍了VB.net可编程地下拉DateTimePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所有的代码在这里:

 调用SendMessage(dtPicker.Handle,CB_SHOWDROPDOWN,True,0&)

在组合框中工作正常,但在DateTimePicker框中似乎不起作用。 p>

可能是什么问题?



谢谢!



David

解决方案

不,这是一个ComboBox。本机DTP控件是非常肮脏的。它支持DTM_CLOSEMONTHCAL消息关闭日历,但没有相应的消息来打开它。你必须做一些像假鼠标或键盘输入一样丑陋的东西。后者可能是最好的:

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


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

解决方案

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

这篇关于VB.net可编程地下拉DateTimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆