如何在VB.net中实现DateTimePicker月份点击事件的捕获?
- 内容介绍
- 相关推荐
本文共计262个文字,预计阅读时间需要2分钟。
如何检查DateTimePicker的月份箭头点击事件。当我试图更改datetimepicker的月份时,它将给出下个月的第一天,所以我需要阻止该月份的点击。请看图片:非常感谢。混合使用CloseUp和Dropdown事件。“
如何检查DateTimePicker的月份箭头单击事件.当我试图更改datetimepicker的月份时,它会给出下个月的第一个日期,所以我要阻止那个月点击.请看图片:
非常感谢.
混合使用CloseUp和DropDown事件以及绑定数据可能是解决方案Imports System.Windows.Forms Namespace WindowsFormsApplication1 Public Partial Class Form1 Inherits Form Private isDropedDown As Boolean Private m_dataSale As DateTime = DateTime.Now Public Property DataSale() As DateTime Get Return m_dataSale End Get Set If isDropedDown Then If m_dataSale.[Date].AddMonths(1).[Date] = value.[Date] OrElse m_dataSale.[Date].AddMonths(-1).[Date] = value.[Date] OrElse New DateTime(m_dataSale.Year, m_dataSale.Month, 1).AddMonths(1).[Date] = value.[Date] OrElse New DateTime(m_dataSale.Year, m_dataSale.Month, 1).AddMonths(-1).[Date] = value.[Date] Then MessageBox.Show("Month is changing") End If End If m_dataSale = value End Set End Property Public Sub New() InitializeComponent() Dim binding = dateTimePicker1.DataBindings.Add("Value", Me, "DataSale") binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged End Sub Private Sub dateTimePicker1_CloseUp(sender As Object, e As EventArgs) isDropedDown = False End Sub Private Sub dateTimePicker1_DropDown(sender As Object, e As EventArgs) isDropedDown = True End Sub End Class End Namespace
本文共计262个文字,预计阅读时间需要2分钟。
如何检查DateTimePicker的月份箭头点击事件。当我试图更改datetimepicker的月份时,它将给出下个月的第一天,所以我需要阻止该月份的点击。请看图片:非常感谢。混合使用CloseUp和Dropdown事件。“
如何检查DateTimePicker的月份箭头单击事件.当我试图更改datetimepicker的月份时,它会给出下个月的第一个日期,所以我要阻止那个月点击.请看图片:
非常感谢.
混合使用CloseUp和DropDown事件以及绑定数据可能是解决方案Imports System.Windows.Forms Namespace WindowsFormsApplication1 Public Partial Class Form1 Inherits Form Private isDropedDown As Boolean Private m_dataSale As DateTime = DateTime.Now Public Property DataSale() As DateTime Get Return m_dataSale End Get Set If isDropedDown Then If m_dataSale.[Date].AddMonths(1).[Date] = value.[Date] OrElse m_dataSale.[Date].AddMonths(-1).[Date] = value.[Date] OrElse New DateTime(m_dataSale.Year, m_dataSale.Month, 1).AddMonths(1).[Date] = value.[Date] OrElse New DateTime(m_dataSale.Year, m_dataSale.Month, 1).AddMonths(-1).[Date] = value.[Date] Then MessageBox.Show("Month is changing") End If End If m_dataSale = value End Set End Property Public Sub New() InitializeComponent() Dim binding = dateTimePicker1.DataBindings.Add("Value", Me, "DataSale") binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged End Sub Private Sub dateTimePicker1_CloseUp(sender As Object, e As EventArgs) isDropedDown = False End Sub Private Sub dateTimePicker1_DropDown(sender As Object, e As EventArgs) isDropedDown = True End Sub End Class End Namespace

