winforms – 以编程方式打开DateTimePicker C#控件
发布时间:2020-12-15 07:53:48 所属栏目:百科 来源:网络整理
导读:如何以编程方式打开 DateTimePicker C#控件? 我想通过向控件发送密钥来在Datetime Picker控件中显示Calender. 有没有办法可以做到这一点? 谢谢 解决方法 请尝试以下方法 //part of the usingsusing System.Runtime.InteropServices;//declares[DllImport("
如何以编程方式打开
DateTimePicker C#控件?
我想通过向控件发送密钥来在Datetime Picker控件中显示Calender. 有没有办法可以做到这一点? 谢谢 解决方法
请尝试以下方法
//part of the usings using System.Runtime.InteropServices; //declares [DllImport("user32.dll")] private static extern bool PostMessage( IntPtr hWnd,// handle to destination window Int32 msg,// message Int32 wParam,// first message parameter Int32 lParam // second message parameter ); const Int32 WM_LBUTTONDOWN = 0x0201; //method to call dropdown private void button1_Click(object sender,EventArgs e) { Int32 x = dateTimePicker1.Width - 10; Int32 y = dateTimePicker1.Height / 2; Int32 lParam = x + y * 0x00010000; PostMessage(dateTimePicker1.Handle,WM_LBUTTONDOWN,1,lParam); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |