tags:

views:

79

answers:

1
+1  Q: 

Date time picker

hai, I'm using vb.net, in which i have a date time picker. I need to get a message when i change to date. I had done it with TextChanged event,But when i click the selection button of datetime picker the message is asking two times. How can i over come this. The code that i write in text changed events is as follows:

Private Sub dtpUptoFrom_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtpUptoFrom.TextChanged
        If bolDateChanged = True Then
            If objClsMsg.Show(Global.Components.clsMessagebox.errorTypes.userMsg, "This operation will reset the item details. Do you want to continue?", "", Global.Components.clsMessagebox.Buttons.YesNo, Global.Components.clsMessagebox.Icons.Question) = Global.Components.clsMessagebox.DialogResult.Yes Then
                If lngGateInId > 0 Then
                    Fill_ItemNames(lngGateInId)
                End If
            Else
                bolDateChanged = False
                dtpUptoFrom.Text = objClscom.GetServerDateTime
                ''cmbUptoBetween.SelectedIndex = 0
                bolDateChanged = True

            End If
        Else
            If enmOperation = Operations.Insert Then
                If lngGateInId > 0 Then
                    Fill_ItemNames(lngGateInId)
                End If
            End If
        End If
         End Sub

how can i solve this?

+2  A: 

Your sub dtpUptoFrom_TextChanged, which handles the TextChanged event, changes the dtpUptoFrom.Text property, which in turn triggers another TextChanged event.

You should consider using the ValueChanged event instead of the TextChanged event, and/or utilizing the Validation model.

M.A. Hanin