gpt4 book ai didi

vb.net - 在日期选择器中浏览月份时如何不触发 datepicker.valuechanged 事件

转载 作者:行者123 更新时间:2023-12-02 09:37:32 24 4
gpt4 key购买 nike

我正在使用vb.net。我添加一个日期选择器如下

Friend WithEvents dtpReportDate As System.Windows.Forms.DateTimePicker

默认的日期选择器有向左箭头和向右箭头,允许您浏览上个月和下个月。我向日期选择器 valuechanged 事件添加一个处理程序:

AddHandler dtpReportDate.ValueChanged, AddressOf dtpReportDateChanged

Private Sub dtpReportDateChanged(ByVal 发送者作为对象,ByVal e 作为 System.EventArgs)

'在这里做点什么

结束子

问题是,每当我单击向左箭头或向右箭头更改月份时,都会触发 dptReportDateChanged。我不希望这种情况发生。我想要的只是找到一个月后,双击日期来触发事件。

非常感谢!

最佳答案

试试这个:

Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DateTimePicker1.ValueChanged
Me.Text = DateTimePicker1.Value.ToString
End Sub

Private Sub DateTimePicker1_DropDown(ByVal sender As Object, ByVal e As EventArgs) Handles DateTimePicker1.DropDown
RemoveHandler DateTimePicker1.ValueChanged, AddressOf DateTimePicker1_ValueChanged
End Sub

Private Sub DateTimePicker1_CloseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.CloseUp
AddHandler DateTimePicker1.ValueChanged, AddressOf DateTimePicker1_ValueChanged
Call DateTimePicker1_ValueChanged(sender, EventArgs.Empty)
End Sub

关于vb.net - 在日期选择器中浏览月份时如何不触发 datepicker.valuechanged 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7406933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com