Get the month click for DateTimePicker in VB.NET

How to check the month arrow click event of DateTimePicker. When I try to change the month of the datetimepicker, it will give the first date of the next month, so I want to prevent that month from clicking .

Please see the picture:

Thank you very much.

Mixing CloseUp and DropDown events and binding data may be the solution

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

How to check the month arrow click event of DateTimePicker. When I try to change the month of the datetimepicker, it will give the first date of the next month, so I To prevent clicks that month.

Please see the picture:

Thank you very much.

p>

Mixed use of CloseUp and DropDown events and binding data may be the solution

Imports System.Windows.Forms< br />
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< /pre>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3439 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.