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

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

问题描述

嘿,我这里有这个代码:

Hey all i have this code here:

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

这在组合框上工作正常,但在 DateTimePicker 框上似乎不起作用.

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

可能是什么问题?

谢谢!

大卫

推荐答案

不,那是针对 ComboBox 的.原生 DTP 控制非常好.它支持 DTM_CLOSEMONTHCAL 消息来关闭日历,但没有相应的消息来打开它.你将不得不做一些丑陋的事情,比如伪造鼠标或键盘输入.后者可能是最好的:

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天全站免登陆